public void ReadFromReturnsCorrectResult( XmlContentSerializer serializer, XmlAtomContent seed, XmlAttributedTestEventX tex) { var expected = seed.WithItem(tex); using (var sr = new StringReader(expected.ToXmlString(serializer))) using (var r = XmlReader.Create(sr)) { XmlAtomContent actual = XmlAtomContent.ReadFrom(r, serializer); Assert.Equal(expected, actual); } }
public void SutCanRoundTripToString( XmlContentSerializer serializer, XmlAtomContent seed, XmlAttributedTestEventX tex) { var expected = seed.WithItem(tex); var xml = expected.ToXmlString(serializer); XmlAtomContent actual = XmlAtomContent.Parse(xml, serializer); Assert.Equal(expected, actual); }
public void WithItemReturnsCorrectResult( XmlAtomContent sut, object newItem) { XmlAtomContent actual = sut.WithItem(newItem); var expected = actual.AsSource().OfLikeness<XmlAtomContent>() .With(x => x.Item).EqualsWhen( (s, d) => object.Equals(newItem, s.Item)); expected.ShouldEqual(actual); }
public void WriteToXmlWriterWritesCorrectXml( XmlContentSerializer serializer, XmlAtomContent content, AtomEntry entry, XmlAttributedTestEventX tex) { // Fixture setup var sb = new StringBuilder(); using (var w = XmlWriter.Create(sb)) { var sut = content.WithItem(tex); // Exercise system sut.WriteTo(w, serializer); // Verify outcome w.Flush(); var expected = XDocument.Parse( "<content type=\"application/xml\" xmlns=\"http://www.w3.org/2005/Atom\">" + " <test-event-x xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns=\"http://grean:rocks\">" + " <number>" + tex.Number + "</number>" + " <text>" + tex.Text + "</text>" + " </test-event-x>" + "</content>"); var actual = XDocument.Parse(sb.ToString()); Assert.Equal(expected, actual, new XNodeEqualityComparer()); // Teardown } }
public void SutEqualsIdenticalOther(XmlAtomContent sut) { var other = sut.WithItem(sut.Item); var actual = sut.Equals(other); Assert.True(actual); }