AddToGroup test
This commit is contained in:
parent
edd8d7978e
commit
e08fca912f
@ -21,6 +21,13 @@ namespace BenchtopParser {
|
|||||||
public Dictionary<String, Configuration> U = new Dictionary<String, Configuration>();
|
public Dictionary<String, Configuration> U = new Dictionary<String, Configuration>();
|
||||||
public Dictionary<String, Configuration> X = 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) {
|
public void AddToGroup(String group, Configuration config) {
|
||||||
// UGLY - but helpful later.
|
// UGLY - but helpful later.
|
||||||
// TODO: Find out what the config names are and MAKE A MAP
|
// 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 "T": this.T.Add(name, config); break;
|
||||||
case "U": this.U.Add(name, config); break;
|
case "U": this.U.Add(name, config); break;
|
||||||
case "X": this.X.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 class Configuration {
|
||||||
public String? name { get; set; }
|
public String name { get; set; }
|
||||||
public String? value { get; set; }
|
public String? value { get; set; }
|
||||||
public String? unit { 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 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) {
|
public Configuration(List<String> config, String data) {
|
||||||
String[] nameValue = data.Split("=");
|
String[] nameValue = data.Split("=");
|
||||||
|
@ -34,5 +34,19 @@ namespace BenchtopParserTests {
|
|||||||
Exception ex = Assert.Throws<Exception>(delegate { new BenchtopParser.ProgramConfig("broken"); });
|
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"));
|
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));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user