public void EmPropertyCollection_WithNestedCollection_ToString_GetExpected() { var nestedComplex = new TestSimpleCollection("Nested", new List <EmProperty> { new EmProperty <string>("Nstring", "Nval"), new EmProperty <int>("Nint", 10), }); var properties = new List <EmProperty> { new EmProperty <string>("String", "Val"), new EmProperty <int>("Int", 12), new EmPropertyList <float>("FloatList", new List <float> { 1.0f, 2.1f, 3.2f }), nestedComplex }; var testProp = new TestSimpleCollection("TestKey", properties); const string expectedValue = "TestKey:" + "(" + "String:Val;" + "Int:12;" + "FloatList:1,2.1,3.2;" + "Nested:" + "(" + "Nstring:Nval;" + "Nint:10;" + ");" + ");"; Assert.AreEqual(expectedValue, testProp.ToString()); }
public void EmPropertyCollection_WithNestedCollection_ToAndFromString_DataPreserved() { var nestedComplexOrig = new TestSimpleCollection("Nested", new List <EmProperty> { new EmProperty <string>("Nstring", "Nval"), new EmProperty <int>("Nint", 10), }); const string text = "Val : has ; special"; const int number = 12; var list = new List <float> { 1.0f, 2.1f, 3.2f }; var propertiesOrig = new List <EmProperty> { new EmProperty <string>("String", text), new EmProperty <int>("Int", number), new EmPropertyList <float>("FloatList", list), nestedComplexOrig }; var orig = new TestSimpleCollection("TestKey", propertiesOrig); var nestedComplex = new TestSimpleCollection("Nested", new List <EmProperty> { new EmProperty <string>("Nstring"), new EmProperty <int>("Nint"), }); var properties = new List <EmProperty> { new EmProperty <string>("String"), new EmProperty <int>("Int"), new EmPropertyList <float>("FloatList"), nestedComplex }; var deserialized = new TestSimpleCollection("TestKey", properties); string originalSerialized = orig.ToString(); deserialized.FromString(originalSerialized); string serialized = deserialized.ToString(); Assert.AreEqual(originalSerialized, serialized); Assert.AreEqual(text, ((EmProperty <string>)deserialized["String"]).Value); Assert.AreEqual(number, ((EmProperty <int>)deserialized["Int"]).Value); Assert.AreEqual(list.Count, ((EmPropertyList <float>)deserialized["FloatList"]).Count); Assert.AreEqual(list[0], ((EmPropertyList <float>)deserialized["FloatList"])[0]); Assert.AreEqual(list[1], ((EmPropertyList <float>)deserialized["FloatList"])[1]); Assert.AreEqual(list[2], ((EmPropertyList <float>)deserialized["FloatList"])[2]); Assert.AreEqual("Nval", ((EmProperty <string>)((EmPropertyCollection)deserialized["Nested"])["Nstring"]).Value); Assert.AreEqual(10, ((EmProperty <int>)((EmPropertyCollection)deserialized["Nested"])["Nint"]).Value); }
public void EmPropertyCollection_WithNestedCollection_ToAndFromString_DataPreserved() { var nestedComplexOrig = new TestSimpleCollection("Nested", new List <EmProperty> { new EmProperty <string>("Nstring", "Nval"), new EmProperty <int>("Nint", 10), }); var propertiesOrig = new List <EmProperty> { new EmProperty <string>("String", "Val"), new EmProperty <int>("Int", 12), new EmPropertyList <float>("FloatList", new List <float> { 1.0f, 2.1f, 3.2f }), nestedComplexOrig }; var orig = new TestSimpleCollection("TestKey", propertiesOrig); var nestedComplex = new TestSimpleCollection("Nested", new List <EmProperty> { new EmProperty <string>("Nstring"), new EmProperty <int>("Nint"), }); var properties = new List <EmProperty> { new EmProperty <string>("String"), new EmProperty <int>("Int"), new EmPropertyList <float>("FloatList"), nestedComplex }; var deserialized = new TestSimpleCollection("TestKey", properties); string originalSerialized = orig.ToString(); deserialized.FromString(originalSerialized); string serialized = deserialized.ToString(); Assert.AreEqual(originalSerialized, serialized); Assert.AreEqual("Val", ((EmProperty <string>)deserialized["String"]).Value); Assert.AreEqual(12, ((EmProperty <int>)deserialized["Int"]).Value); Assert.AreEqual(3, ((EmPropertyList <float>)deserialized["FloatList"]).Count); Assert.AreEqual(1.0f, ((EmPropertyList <float>)deserialized["FloatList"])[0]); Assert.AreEqual(2.1f, ((EmPropertyList <float>)deserialized["FloatList"])[1]); Assert.AreEqual(3.2f, ((EmPropertyList <float>)deserialized["FloatList"])[2]); Assert.AreEqual("Nval", ((EmProperty <string>)((EmPropertyCollection)deserialized["Nested"])["Nstring"]).Value); Assert.AreEqual(10, ((EmProperty <int>)((EmPropertyCollection)deserialized["Nested"])["Nint"]).Value); }
public void EmPropertyCollection_NoNestedComplex_ToString_GetExpected(string stValue, string escapedValue) { var properties = new List <EmProperty>() { new EmProperty <string>("String", stValue), new EmProperty <int>("Int", 12), new EmPropertyList <float>("FloatList", new List <float> { 1.0f, 2.1f, 3.2f }), }; var testProp = new TestSimpleCollection("TestKey", properties); string expectedValue = "TestKey:" + "(" + $"String:{escapedValue};" + "Int:12;" + "FloatList:1,2.1,3.2;" + ");"; Assert.AreEqual(expectedValue, testProp.ToString()); }