2022-07-25 04:51:43 +00:00
|
|
|
namespace BenchtopParserTests {
|
2022-07-26 05:23:41 +00:00
|
|
|
public class Program_Config_Tests {
|
|
|
|
public String program_config_value;
|
|
|
|
|
2022-07-25 04:51:43 +00:00
|
|
|
[SetUp]
|
|
|
|
public void Setup() {
|
2022-07-26 05:30:36 +00:00
|
|
|
program_config_value = File.ReadAllText(
|
|
|
|
Path.Combine(TestContext.CurrentContext.TestDirectory, @"TestFiles\Program Config.txt")
|
|
|
|
);
|
2022-07-25 04:51:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
public void Test_ProgramConfig() {
|
2022-07-26 05:52:37 +00:00
|
|
|
BenchtopParser.ProgramConfig programConfigs = new(program_config_value);
|
2022-07-26 04:59:04 +00:00
|
|
|
Assert.IsNotNull(programConfigs);
|
2022-07-25 04:51:43 +00:00
|
|
|
|
|
|
|
// Check that group collecting works -
|
2022-07-27 00:13:20 +00:00
|
|
|
Assert.That(programConfigs.Programs["P1"].I["3"].Value, Is.EqualTo("Unassigned"));
|
|
|
|
Assert.That(programConfigs.Programs["P1"].O["3"].Value, Is.EqualTo("Test Passed"));
|
2022-07-26 04:27:58 +00:00
|
|
|
|
2022-07-27 00:13:20 +00:00
|
|
|
Assert.That(programConfigs.Programs["P1"].P["Minimum Pressure"].Value, Is.EqualTo("95.000"));
|
|
|
|
Assert.That(programConfigs.Programs["P1"].P["Minimum Pressure"].Unit, Is.EqualTo("mbar"));
|
|
|
|
Assert.That(programConfigs.Programs["P1"].P["Minimum Pressure"].Type, Is.EqualTo("f"));
|
2022-07-25 04:51:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
public void Test_ProgramConfig_Throw_ErrorOrder() {
|
2022-07-26 05:34:45 +00:00
|
|
|
Exception ex = Assert.Throws<Exception>(delegate { new BenchtopParser.ProgramConfig("EBAE006 L 1,P1"); });
|
2022-07-25 04:51:43 +00:00
|
|
|
Assert.That(ex.Message, Is.EqualTo("Setting Program Number Before Start. Error In Config"));
|
|
|
|
}
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
public void Test_ProgramConfig_Throw_InvalidProgram() {
|
2022-07-26 05:34:45 +00:00
|
|
|
Exception ex = Assert.Throws<Exception>(delegate { new BenchtopParser.ProgramConfig("broken"); });
|
2022-07-25 04:51:43 +00:00
|
|
|
Assert.That(ex.Message, Is.EqualTo("Invalid Program Config, please provide an I28 Program Config file data"));
|
|
|
|
}
|
2022-07-26 05:48:18 +00:00
|
|
|
|
|
|
|
[Test]
|
|
|
|
public void Test_ProgramConfig_AddToGroup() {
|
|
|
|
// Adds the "namename" config to X group
|
2022-07-26 05:52:37 +00:00
|
|
|
BenchtopParser.Configuration config = new("namename", "b", "c", "d");
|
2022-07-26 05:48:18 +00:00
|
|
|
String group = "x"; //testing force upper check too.
|
2022-07-26 05:52:37 +00:00
|
|
|
BenchtopParser.Program program = new();
|
2022-07-26 05:48:18 +00:00
|
|
|
program.AddToGroup(group, config);
|
|
|
|
|
2022-07-26 05:56:22 +00:00
|
|
|
BenchtopParser.Configuration check = program.X["namename"];
|
2022-07-26 05:48:18 +00:00
|
|
|
Assert.That(check, Is.EqualTo(config));
|
|
|
|
}
|
2022-07-25 04:51:43 +00:00
|
|
|
}
|
|
|
|
}
|