public void ToXmlStringWithSettingsReturnsCorrectResult( TestXmlWritable writable, IContentSerializer dummySerializer) { var settings = new XmlWriterSettings { OmitXmlDeclaration = true }; var actual = writable.ToXmlString(dummySerializer, settings); var sb = new StringBuilder(); using (var w = XmlWriter.Create(sb, settings)) { writable.WriteTo(w); w.Flush(); } var expected = XDocument.Parse(sb.ToString()); Assert.Equal( expected, XDocument.Parse(actual), new XNodeEqualityComparer()); Assert.False( actual.StartsWith("<?"), "XML declaration not expected due to XmlWriterSettings"); }
public void ToXmlStringWithSettingsReturnsCorrectResult( TestXmlWritable writable, IContentSerializer dummySerializer) { var settings = new XmlWriterSettings { OmitXmlDeclaration = true }; var actual = writable.ToXmlString(dummySerializer, settings); var sb = new StringBuilder(); using (var w = XmlWriter.Create(sb, settings)) { writable.WriteTo(w); w.Flush(); } var expected = XDocument.Parse(sb.ToString()); Assert.Equal( expected, XDocument.Parse(actual), new XNodeEqualityComparer()); Assert.False( actual.StartsWith("<?"), "XML declaration not expected due to XmlWriterSettings"); }
public void ToXmlStringReturnsCorrectResult( TestXmlWritable writable, IContentSerializer dummySerializer) { var actual = writable.ToXmlString(dummySerializer); var sb = new StringBuilder(); using (var w = XmlWriter.Create(sb)) { writable.WriteTo(w); w.Flush(); } var expected = XDocument.Parse(sb.ToString()); Assert.Equal( expected, XDocument.Parse(actual), new XNodeEqualityComparer()); }
public void ToXmlStringReturnsCorrectResult( TestXmlWritable writable, IContentSerializer dummySerializer) { var actual = writable.ToXmlString(dummySerializer); var sb = new StringBuilder(); using (var w = XmlWriter.Create(sb)) { writable.WriteTo(w); w.Flush(); } var expected = XDocument.Parse(sb.ToString()); Assert.Equal( expected, XDocument.Parse(actual), new XNodeEqualityComparer()); }