public static string CreateTestXML() { var types = new System.Collections.Generic.List <System.Type>(); types.Add(typeof(WithXmlAttributesDefined)); var serializer = XmlSerializer.FromTypes(types.ToArray()).First(); var testObject = new WithXmlAttributesDefined(); testObject.Foo = "stringvalue"; testObject.MightBeAAttribute = "stringvalue"; testObject.StringArray = new string[] { "S1" }; testObject.TheInts = new int[] { 1 }; testObject.InternalItems = new[] { new WithXmlAttributeItem() { Name = "Test" } }; testObject.ReferenceProperty = new WithXmlAttributeProperty() { Name = "Test" }; testObject.ExternalItems2 = new[] { new WithXmlAttributeItem2() { Name = "Test" } }; 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(); }