public void ToXml()
 {
     var dummy = new DataContractDummy { Value = 2 };
     var xml = DataContractSerializerAssert.ToXml(dummy);
     var expected = "<?xml version=\"1.0\" encoding=\"utf-16\"?>\r\n" +
                    "<DataContractDummy xmlns:i=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns=\"http://schemas.datacontract.org/2004/07/Gu.SerializationAsserts.Tests.Dtos\">\r\n" +
                    "  <Value>2</Value>\r\n" +
                    "</DataContractDummy>";
     Assert.AreEqual(expected, xml);
 }
 public void Equal()
 {
     var actual = new DataContractDummy { Value = 2 };
     var expectedXml = "<?xml version=\"1.0\" encoding=\"utf-16\"?>\r\n" +
                       "<DataContractDummy xmlns:i=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns=\"http://schemas.datacontract.org/2004/07/Gu.SerializationAsserts.Tests.Dtos\">\r\n" +
                       "  <Value>2</Value>\r\n" +
                       "</DataContractDummy>";
     var roundtrip = DataContractSerializerAssert.Equal(expectedXml, actual);
     Assert.AreEqual(roundtrip.Value, actual.Value);
     FieldAssert.Equal(actual, roundtrip);
 }
 public void NotEqualItems()
 {
     var expected = new DataContractDummy { Value = 1 };
     var actual = new DataContractDummy { Value = 2 };
     var ex = Assert.Throws<AssertException>(() => DataContractSerializerAssert.Equal(expected, actual));
     var expectedMessage = "  Xml differ at line 3 index 7.\r\n" +
                           "  Expected: 3| <Value>1</Value>\r\n" +
                           "  But was:  3| <Value>2</Value>\r\n" +
                           "  --------------------^";
     Assert.AreEqual(expectedMessage, ex.Message);
 }
 public void EqualItems()
 {
     var expected = new DataContractDummy { Value = 2 };
     var actual = new DataContractDummy { Value = 2 };
     DataContractSerializerAssert.Equal(expected, actual);
 }
 public void EqualNoDeclarationOrNamespaces()
 {
     var actual = new DataContractDummy { Value = 2 };
     var expectedXml = "<DataContractDummy>\r\n" +
                       "  <Value>2</Value>\r\n" +
                       "</DataContractDummy>";
     var roundtrip = DataContractSerializerAssert.Equal(expectedXml, actual, XmlAssertOptions.IgnoreDeclaration | XmlAssertOptions.IgnoreNamespaces);
     Assert.AreEqual(roundtrip.Value, actual.Value);
     FieldAssert.Equal(actual, roundtrip);
 }