52 lines
2.3 KiB
C#
52 lines
2.3 KiB
C#
namespace BenchtopParserTests {
|
|
public class Program_Config_Tests {
|
|
public String program_config_value;
|
|
|
|
[SetUp]
|
|
public void Setup() {
|
|
program_config_value = File.ReadAllText(
|
|
Path.Combine(TestContext.CurrentContext.TestDirectory, @"TestFiles\Program Config.txt")
|
|
);
|
|
}
|
|
|
|
[Test]
|
|
public void Test_ProgramConfig() {
|
|
var programConfigs = new BenchtopParser.ProgramConfig(program_config_value);
|
|
Assert.IsNotNull(programConfigs);
|
|
|
|
// Check that group collecting works -
|
|
Assert.That(programConfigs.programs["P1"].I["3"].value, Is.EqualTo("Unassigned"));
|
|
Assert.That(programConfigs.programs["P1"].O["3"].value, Is.EqualTo("Test Passed"));
|
|
|
|
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"));
|
|
}
|
|
|
|
[Test]
|
|
public void Test_ProgramConfig_Throw_ErrorOrder() {
|
|
Exception ex = Assert.Throws<Exception>(delegate { new BenchtopParser.ProgramConfig("EBAE006 L 1,P1"); });
|
|
Assert.That(ex.Message, Is.EqualTo("Setting Program Number Before Start. Error In Config"));
|
|
}
|
|
|
|
[Test]
|
|
public void Test_ProgramConfig_Throw_InvalidProgram() {
|
|
Exception ex = Assert.Throws<Exception>(delegate { new BenchtopParser.ProgramConfig("broken"); });
|
|
Assert.That(ex.Message, Is.EqualTo("Invalid Program Config, please provide an I28 Program Config file data"));
|
|
}
|
|
|
|
[Test]
|
|
public void Test_ProgramConfig_AddToGroup() {
|
|
// Adds the "namename" config to X group
|
|
BenchtopParser.Configuration config = new BenchtopParser.Configuration("namename", "b", "c", "d");
|
|
String group = "x"; //testing force upper check too.
|
|
BenchtopParser.Program program = new BenchtopParser.Program();
|
|
|
|
program.ProgramNumber = "P1";
|
|
program.AddToGroup(group, config);
|
|
|
|
var check = program.X["namename"];
|
|
Assert.That(check, Is.EqualTo(config));
|
|
}
|
|
}
|
|
} |