AddToGroup test

This commit is contained in:
Tyrel Souza 2022-07-26 01:48:18 -04:00
parent edd8d7978e
commit e08fca912f
2 changed files with 29 additions and 1 deletions

View File

@ -21,6 +21,13 @@ namespace BenchtopParser {
public Dictionary<String, Configuration> U = new Dictionary<String, Configuration>();
public Dictionary<String, Configuration> X = new Dictionary<String, Configuration>();
public string Name() {
if (M != null && M["Name"] != null && M["Name"].value != null) {
return M["Name"].value;
}
return "";
}
public void AddToGroup(String group, Configuration config) {
// UGLY - but helpful later.
// TODO: Find out what the config names are and MAKE A MAP
@ -40,17 +47,24 @@ namespace BenchtopParser {
case "T": this.T.Add(name, config); break;
case "U": this.U.Add(name, config); break;
case "X": this.X.Add(name, config); break;
default: throw new Exception($"No group {group} configured. Please fix configuration");
}
}
}
public class Configuration {
public String? name { get; set; }
public String name { get; set; }
public String? value { get; set; }
public String? unit { get; set; }
public String? type { get; set; } //possible values are: a, c, f, i. Which I presume are Array, Characters, Float, Integer
public Configuration(string name, string? value, string? unit, string? type) {
this.name = name;
this.value = value;
this.unit = unit;
this.type = type;
}
public Configuration(List<String> config, String data) {
String[] nameValue = data.Split("=");

View File

@ -34,5 +34,19 @@ namespace BenchtopParserTests {
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));
}
}
}