Add exception test

This commit is contained in:
Tyrel Souza 2022-07-25 00:16:15 -04:00
parent db92ab8de3
commit 86bbb3067b
2 changed files with 6 additions and 5 deletions

View File

@ -6,6 +6,9 @@
foreach (var line in program_config.Split(new string[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries)) { foreach (var line in program_config.Split(new string[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries)) {
var config_line = line.Split("\t").ToList(); var config_line = line.Split("\t").ToList();
if (config_line.Count() < 2) {
throw new Exception("Invalid Program Config, please provide an I28 Program Config file data");
}
config_line.RemoveAt(0); // Remove random hex value config_line.RemoveAt(0); // Remove random hex value
config_line.RemoveAt(0); // Remove L column config_line.RemoveAt(0); // Remove L column
if (config_line[0].StartsWith("Start,")) { if (config_line[0].StartsWith("Start,")) {

View File

@ -13,12 +13,10 @@ namespace BenchtopParserTests {
Assert.IsNotNull(configs); Assert.IsNotNull(configs);
} }
[Test]
public void Test_ProgramConfig_Throw_ErrorOrder() { public void Test_ProgramConfig_Throw_ErrorOrder() {
String program_config = File.ReadAllText( Exception ex = Assert.Throws<Exception>(delegate { BenchtopParser.Parser.I28_ProgramConfig("broken"); });
Path.Combine(TestContext.CurrentContext.TestDirectory, @"TestFiles\Program Config.txt") Assert.That(ex.Message, Is.EqualTo("Invalid Program Config, please provide an I28 Program Config file data"));
);
var configs = BenchtopParser.Parser.I28_ProgramConfig(program_config);
Assert.IsNotNull(configs);
} }
} }
} }