public void ParseTest2() { string val = " val1: field1 ,field2 ;val2:field3, field4, field5;"; var actual = FieldSwitch.Parse(val, "mainField", new Dictionary <string, string> { { "mainField", "mainFieldID" }, { "field1", "field1ID" }, { "field2", "field2ID" }, { "field4", "field4ID" }, { "field5", "field5ID" } }); Assert.AreEqual(2, actual.switches.Count); Assert.AreEqual("mainField", actual.field.fieldName); Assert.AreEqual("mainFieldID", actual.field.fieldId); Assert.AreEqual("val1", actual.switches[0].value); Assert.AreEqual("val2", actual.switches[1].value); Assert.AreEqual(2, actual.switches[0].fields.Count, 2); Assert.AreEqual(3, actual.switches[1].fields.Count, 2); Assert.AreEqual("field1", actual.switches[0].fields[0].fieldName); Assert.AreEqual("field1ID", actual.switches[0].fields[0].fieldId); Assert.AreEqual("field2", actual.switches[0].fields[1].fieldName); Assert.AreEqual("field2ID", actual.switches[0].fields[1].fieldId); Assert.AreEqual("field4", actual.switches[1].fields[0].fieldName); Assert.AreEqual("field4ID", actual.switches[1].fields[0].fieldId); Assert.AreEqual("field5", actual.switches[1].fields[1].fieldName); Assert.AreEqual("field5ID", actual.switches[1].fields[1].fieldId); }
public void ToJsonTest() { string val = " val1: field1 ,field2 ;val2:field3, field4, field5;"; var actual = FieldSwitch.Parse(val, "mainField", new Dictionary <string, string> { { "mainField", "mainFieldID" }, { "field1", "field1ID" }, { "field2", "field2ID" }, { "field4", "field4ID" }, { "field5", "field5ID" } }); var test = new FieldsSwitches(); test.Add(actual); test.Add(actual); var res = test.ToJson(); Assert.IsNotNull(res); Assert.IsTrue(res.Length > 0); }