public void Serialize_Test1() { // Arrange var author = new MockAuthor() { Firstname = "John", Lastname = "Smith", Books = { new MockBook { ISBN = "0123456788", Title = "Hello World!" }, new MockBook { ISBN = "0123456789", Title = "Hello World: Part 2" } } }; // Act string xmlString; author.Serialize(out xmlString); // Assert Assert.NotNull(xmlString); Assert.Contains("utf-8", xmlString); Assert.Contains("<MockAuthor", xmlString); Assert.Contains("<ISBN>0123456789</ISBN>", xmlString); }
public void Serialize_XmlWriterSettings() { // Arrange var author = new MockAuthor { Firstname = "Bill" }; // Act string xmlString; author.Serialize(new XmlWriterSettings { Encoding = Encoding.ASCII }, out xmlString); // Assert Assert.NotNull(xmlString); Assert.Contains("us-ascii", xmlString); Assert.Contains("<Firstname>Bill</Firstname>", xmlString); }