From e20a064fa9977c6b715dfd0f5e36d89277f4a237 Mon Sep 17 00:00:00 2001 From: Tyrel Souza Date: Tue, 26 Jul 2022 02:04:19 -0400 Subject: [PATCH] testing SetIndent and SplitLine --- BenchtopParser/TransducerVerify.cs | 7 ++++-- .../Transducer_Verify_Tests.cs | 22 +++++++++++++++++++ 2 files changed, 27 insertions(+), 2 deletions(-) diff --git a/BenchtopParser/TransducerVerify.cs b/BenchtopParser/TransducerVerify.cs index b0c6a48..84c07cb 100644 --- a/BenchtopParser/TransducerVerify.cs +++ b/BenchtopParser/TransducerVerify.cs @@ -8,7 +8,7 @@ namespace BenchtopParser { public class TransducerVerify { public Dictionary 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 @@ -26,6 +26,10 @@ namespace BenchtopParser { this.indent = endOfCurrentTransducerKey - 1 + additionalSpaces; } + public TransducerVerify() { + return; + } + public TransducerVerify(String transducer_verify_value) { string separator = "==============================================================="; List documentLines = transducer_verify_value.Split(new string[] { Environment.NewLine }, StringSplitOptions.TrimEntries).ToList(); @@ -84,6 +88,5 @@ namespace BenchtopParser { public Transducer(int id) { this.id = id; } - } } diff --git a/BenchtopParserTests/Transducer_Verify_Tests.cs b/BenchtopParserTests/Transducer_Verify_Tests.cs index 613fd24..09def04 100644 --- a/BenchtopParserTests/Transducer_Verify_Tests.cs +++ b/BenchtopParserTests/Transducer_Verify_Tests.cs @@ -20,5 +20,27 @@ namespace BenchtopParserTests { Exception ex = Assert.Throws(delegate { new BenchtopParser.TransducerVerify("broken"); }); 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")); + } } } \ No newline at end of file