public void TestStringArrayPropertyToXml() { var serializable = new WithStringArrayProperty() { AnyStrings = new String[] { "MyString1", "MyString2" } }; var xml = serializable.ToXml(); var doc = XDocument.Parse(xml); var elements = doc.XPathSelectElements("/String/AnyStrings/AnyString").ToArray(); Assert.AreEqual("MyString1", elements[0].Value); Assert.AreEqual("MyString2", elements[1].Value); }
public void TestArrayPropertyTypeInfoToXml() { var serializable = new WithStringArrayProperty() { AnyStrings = new String[] { "MyString1" } }; var xml = serializable.ToXml(emitTypeInfo: true); var doc = XDocument.Parse(xml); var arrayElement = doc.XPathSelectElement("/String/AnyStrings"); Assert.AreEqual( typeof(String[]).AssemblyQualifiedName, arrayElement.Attribute(Constants.TypeInfoAttributeName).Value); var arrayItemElement = doc.XPathSelectElement("/String/AnyStrings/AnyString"); Assert.AreEqual( typeof(String).AssemblyQualifiedName, arrayItemElement.Attribute(Constants.TypeInfoAttributeName).Value); }