testing SetIndent and SplitLine

This commit is contained in:
Tyrel Souza 2022-07-26 02:04:19 -04:00
parent b187502d92
commit e20a064fa9
2 changed files with 27 additions and 2 deletions

View File

@ -8,7 +8,7 @@ namespace BenchtopParser {
public class TransducerVerify { public class TransducerVerify {
public Dictionary<int, Transducer> transducers = new(); public Dictionary<int, Transducer> transducers = new();
public int indent = 26; public int indent = 26; // Default 26 from seeing files, overridden later in SetIndent for safety
/// Split the string, and clean up whitespace, returns the Name and Value /// Split the string, and clean up whitespace, returns the Name and Value
@ -26,6 +26,10 @@ namespace BenchtopParser {
this.indent = endOfCurrentTransducerKey - 1 + additionalSpaces; this.indent = endOfCurrentTransducerKey - 1 + additionalSpaces;
} }
public TransducerVerify() {
return;
}
public TransducerVerify(String transducer_verify_value) { public TransducerVerify(String transducer_verify_value) {
string separator = "==============================================================="; string separator = "===============================================================";
List<String> documentLines = transducer_verify_value.Split(new string[] { Environment.NewLine }, StringSplitOptions.TrimEntries).ToList(); List<String> documentLines = transducer_verify_value.Split(new string[] { Environment.NewLine }, StringSplitOptions.TrimEntries).ToList();
@ -84,6 +88,5 @@ namespace BenchtopParser {
public Transducer(int id) { public Transducer(int id) {
this.id = id; this.id = id;
} }
} }
} }

View File

@ -20,5 +20,27 @@ namespace BenchtopParserTests {
Exception ex = Assert.Throws<Exception>(delegate { new BenchtopParser.TransducerVerify("broken"); }); Exception ex = Assert.Throws<Exception>(delegate { new BenchtopParser.TransducerVerify("broken"); });
Assert.That(ex.Message, Is.EqualTo("Invalid Transducer Verify Report, please provide a Transducer Verify Report file data")); Assert.That(ex.Message, Is.EqualTo("Invalid Transducer Verify Report, please provide a Transducer Verify Report file data"));
} }
[Test]
public void Test_TransducerVerify_SetIndent() {
BenchtopParser.TransducerVerify tv = new();
tv.SetIndent(1, "Transducer 1 CTS D34-442 115PSIA");
Assert.That(tv.indent, Is.EqualTo(26));
tv.SetIndent(1, "Transducer 1 CTS D34-442 115PSIA");
Assert.That(tv.indent, Is.EqualTo(20));
tv.SetIndent(1, "Transducer 10CTS D34-442 115PSIA");
Assert.That(tv.indent, Is.EqualTo(11));
}
[Test]
public void Test_TransducerVerify_SplitLine() {
BenchtopParser.TransducerVerify tv = new();
string[] split;
split = tv.SplitLine("Instrument Pressure 1 0.000 psig");
Assert.That(split[0], Is.EqualTo("Instrument Pressure 1"));
Assert.That(split[1], Is.EqualTo("0.000 psig"));
}
} }
} }