public void TestSerializeXmlRootAttributeOnMember() { // nested root XmlAttributeOverrides overrides = new XmlAttributeOverrides(); XmlAttributes childAttr = new XmlAttributes(); childAttr.XmlRoot = new XmlRootAttribute("simple"); overrides.Add(typeof(SimpleClass), childAttr); XmlAttributes attr = new XmlAttributes(); attr.XmlRoot = new XmlRootAttribute("simple"); overrides.Add(typeof(ClassArrayContainer), attr); ClassArrayContainer container = new ClassArrayContainer(); container.items = new SimpleClass[1]; container.items[0] = new SimpleClass(); Serialize(container, overrides); AssertEquals(Infoset("<simple xmlns:xsd='http://www.w3.org/2001/XMLSchema' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' ><items><SimpleClass /></items></simple>"),WriterText); // FIXME test data type }
public void TestSerializeClassArrayContainer() { ClassArrayContainer container = new ClassArrayContainer(); Serialize(container); AssertEquals(Infoset("<ClassArrayContainer xmlns:xsd='http://www.w3.org/2001/XMLSchema' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' />"),WriterText); SimpleClass simple1 = new SimpleClass(); simple1.something = "hello"; SimpleClass simple2 = new SimpleClass(); simple2.something = "hello"; container.items = new SimpleClass[2]; container.items[0] = simple1; container.items[1] = simple2; Serialize(container); AssertEquals(Infoset("<ClassArrayContainer xmlns:xsd='http://www.w3.org/2001/XMLSchema' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' ><items><SimpleClass><something>hello</something></SimpleClass><SimpleClass><something>hello</something></SimpleClass></items></ClassArrayContainer>"),WriterText); }