コード例 #1
0
 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);
     }
 }
コード例 #2
0
        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);
        }
コード例 #3
0
        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);
        }
コード例 #4
0
        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
            }
        }
コード例 #5
0
 public void SutEqualsIdenticalOther(XmlAtomContent sut)
 {
     var other = sut.WithItem(sut.Item);
     var actual = sut.Equals(other);
     Assert.True(actual);
 }