public void TestFromDataType() { IRestDataSerializer serializer = new XmlRestDataSerializer(); XmlTestObject2 actual = serializer.FromDataType <XmlTestObject2>("<?xml version=\"1.0\" encoding=\"utf-16\"?>\r\n<XmlTestObject2 xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\">\r\n <field1>1</field1>\r\n <field2>2</field2>\r\n <field3>true</field3>\r\n</XmlTestObject2>"); Assert.AreEqual <string>("1", actual.field1); Assert.AreEqual <int>(2, actual.field2); Assert.AreEqual <bool>(true, actual.field3); }
public void TestToDataType() { IRestDataSerializer serializer = new XmlRestDataSerializer(); XmlTestObject obj = new XmlTestObject() { field1 = "1", field2 = 2, field3 = true }; string result = serializer.ToDataType <XmlTestObject>(obj); Assert.AreEqual <string>("<?xml version=\"1.0\" encoding=\"utf-16\"?>\r\n<XmlTestObject xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\">\r\n <field1>1</field1>\r\n <field2>2</field2>\r\n <field3>true</field3>\r\n</XmlTestObject>", result); }