Esempio n. 1
0
 public void LinksIsCorrect(
     [Frozen]IEnumerable<AtomLink> expected,
     AtomFeed sut)
 {
     IEnumerable<AtomLink> actual = sut.Links;
     Assert.Equal(expected, actual);
 }
Esempio n. 2
0
 public void EntriesIsCorrect(
     [Frozen]IEnumerable<AtomEntry> expected,
     AtomFeed sut)
 {
     IEnumerable<AtomEntry> actual = sut.Entries;
     Assert.Equal(expected, actual);
 }
Esempio n. 3
0
 public void AuthorIsCorrect(
     [Frozen]AtomAuthor expected,
     AtomFeed sut)
 {
     AtomAuthor actual = sut.Author;
     Assert.Equal(expected, actual);
 }
Esempio n. 4
0
        public void AddLinkReturnsCorrectResult(
            AtomFeed sut,
            AtomLink newLink)
        {
            AtomFeed actual = sut.AddLink(newLink);

            var expected = sut.AsSource().OfLikeness<AtomFeed>()
                .With(x => x.Links).EqualsWhen(
                    (s, d) => sut.Links.Concat(new[] { newLink }).SequenceEqual(d.Links));
            expected.ShouldEqual(actual);
        }
Esempio n. 5
0
        public void ReadFromReturnsCorrectResult(
            XmlContentSerializer serializer,
            AtomFeed feed,
            Generator<XmlAttributedTestEventX> eventGenerator)
        {
            var entries = feed.Entries.Zip(
                eventGenerator,
                (entry, @event) => entry.WithContent(
                    entry.Content.WithItem(@event))).ToList();
            var expected = feed.WithEntries(entries);

            using (var sr = new StringReader(expected.ToXmlString(serializer)))
            using (var r = XmlReader.Create(sr))
            {
                AtomFeed actual = AtomFeed.ReadFrom(r, serializer);
                Assert.Equal(expected, actual, new AtomFeedComparer());
            }
        }
Esempio n. 6
0
 public void IdIsCorrect([Frozen]UuidIri expected, AtomFeed sut)
 {
     UuidIri actual = sut.Id;
     Assert.Equal(expected, actual);
 }
Esempio n. 7
0
        public void WithUpdatedReturnsCorrectResult(
            AtomFeed sut,
            DateTimeOffset newUpdated)
        {
            AtomFeed actual = sut.WithUpdated(newUpdated);

            var expected = sut.AsSource().OfLikeness<AtomFeed>()
                .With(x => x.Updated).EqualsWhen(
                    (s, d) => object.Equals(newUpdated, d.Updated));
            expected.ShouldEqual(actual);
        }
Esempio n. 8
0
 public void SutIsXmlWritable(AtomFeed sut)
 {
     Assert.IsAssignableFrom<IXmlWritable>(sut);
 }
Esempio n. 9
0
        public void WithLinksReturnsCorrectResult(
            AtomFeed sut,
            IEnumerable<AtomLink> newLinks)
        {
            AtomFeed actual = sut.WithLinks(newLinks);

            var expected = sut.AsSource().OfLikeness<AtomFeed>()
                .With(x => x.Links).EqualsWhen(
                    (s, d) => newLinks.SequenceEqual(d.Links));
            expected.ShouldEqual(actual);
        }
Esempio n. 10
0
        public void WithTitleReturnsCorrectResult(
            AtomFeed sut,
            string newTitle)
        {
            AtomFeed actual = sut.WithTitle(newTitle);

            var expected = sut.AsSource().OfLikeness<AtomFeed>()
                .With(x => x.Title).EqualsWhen(
                    (s, d) => object.Equals(newTitle, d.Title));
            expected.ShouldEqual(actual);
        }
Esempio n. 11
0
        public void WithAuthorReturnsCorrectResult(
            AtomFeed sut,
            AtomAuthor newAuthor)
        {
            AtomFeed actual = sut.WithAuthor(newAuthor);

            var expected = sut.AsSource().OfLikeness<AtomFeed>()
                .With(x => x.Author).EqualsWhen(
                    (s, d) => object.Equals(newAuthor, d.Author));
            expected.ShouldEqual(actual);
        }
Esempio n. 12
0
 public void UpdatedIsCorrect(
     [Frozen]DateTimeOffset expected,
     AtomFeed sut)
 {
     DateTimeOffset actual = sut.Updated;
     Assert.Equal(expected, actual);
 }
Esempio n. 13
0
 public void TitleIsCorrect([Frozen]string expected, AtomFeed sut)
 {
     string actual = sut.Title;
     Assert.Equal(expected, actual);
 }
Esempio n. 14
0
 private AtomFeed ReadPage(Uri address)
 {
     using (var r = this.storage.CreateFeedReaderFor(address))
         return(AtomFeed.ReadFrom(r, this.serializer));
 }
Esempio n. 15
0
        public void WriteToXmlWriterWritesCorrectXml(
            XmlContentSerializer serializer,
            AtomXmlWriter<XmlContentSerializer> writer,
            AtomFeed feed,
            Generator<XmlAttributedTestEventX> eventGenerator)
        {
            // Fixture setup
            var sb = new StringBuilder();
            using (var w = XmlWriter.Create(sb))
            {
                var entries = feed.Entries.Zip(
                    eventGenerator,
                    (entry, @event) => entry.WithContent(
                        entry.Content.WithItem(@event))).ToList();
                var sut = feed.WithEntries(entries);

                // Exercise system
                sut.WriteTo(w, serializer);

                // Verify outcome
                w.Flush();

                var expectedLinks = string.Concat(sut.Links.Select(writer.ToXml));
                var expectedEntries = string.Concat(entries.Select(writer.ToXml));

                var expected = XDocument.Parse(
                    "<feed xmlns=\"http://www.w3.org/2005/Atom\">" +
                    "  <id>" + sut.Id.ToString() + "</id>" +
                    "  <title type=\"text\">" + sut.Title + "</title>" +
                    "  <updated>" + sut.Updated.ToString("o") + "</updated>" +
                    "  <author>" +
                    "    <name>" + sut.Author.Name + "</name>" +
                    "  </author>" +
                    expectedLinks +
                    expectedEntries +
                    "</feed>");

                var actual = XDocument.Parse(sb.ToString());
                Assert.Equal(expected, actual, new XNodeEqualityComparer());
            }
            // Teardown
        }
Esempio n. 16
0
 private void Write(AtomFeed feed)
 {
     using (var w = this.storage.CreateFeedWriterFor(feed))
         feed.WriteTo(w, this.serializer);
 }
Esempio n. 17
0
 private bool PageSizeReached(AtomFeed page)
 {
     return(page.Entries.Count() >= this.pageSize);
 }