public void Can_Round_Trip_Serialize_And_Deserialize() { var subject1 = new Subject { SomeStringProperty = "foo", SomeDateProperty = DateTime.Now.AddDays(2) }; string xml = subject1.DataContractSerialize(); var subject2 = xml.DataContractDeserialize<Subject>(); Assert.That(subject1, Is.EqualTo(subject2)); }
public void Can_Serialize_Into_UTF8() { var subject = new Subject {SomeStringProperty = "foo", SomeDateProperty = DateTime.Now.AddDays(2)}; string xml = subject.DataContractSerialize(); XmlDocument doc = new XmlDocument(); doc.LoadXml(xml); XmlDeclaration declaration = doc.ChildNodes.OfType<XmlDeclaration>().First(); Assert.That(string.Equals(declaration.Encoding, "utf-8", StringComparison.InvariantCultureIgnoreCase), Is.True); }