public static string CreateTestXML() { var types = new System.Collections.Generic.List <System.Type>(); types.Add(typeof(WithoutXmlAttributesDefined)); var serializer = XmlSerializer.FromTypes(types.ToArray()).First(); var testObject = new WithoutXmlAttributesDefined(); testObject.Foo = "stringvalue"; testObject.StringArray = new string[] { "S1" }; testObject.IntArray = new int[] { 1 }; testObject.DoubleArray = new double[] { 1 }; testObject.DecimalArray = new decimal[] { 1 }; testObject.InternalItem = new[] { new WithoutXmlAttributesDefined.WithoutXmlAttributeItem() { Name = "Test" } }; testObject.ShouldBeThisPropertyName = new WithXmlAttribute() { Name = "Test2" }; var sio = new System.IO.StringWriter(); serializer.Serialize(sio, testObject); return(sio.ToString()); }
public void When_model_objects_are_created_with_the_example_model_make_sure_that_they_are_serializable() { WithXmlAttributesDefined.CreateTestXml(); WithXmlAttributesDefined.CreateTestArrayXml(); WithoutXmlAttributesDefined.CreateTestXml(); WithoutXmlAttributesDefined.CreateTestArrayXml(); }