Exemplo n.º 1
0
        public async Task Should_return_data_from_rss_feed()
        {
            var httpClient = FakeHttpClientFactory.Create(RssData.Default);
            var reader     = new RssPostReader(httpClient);

            var posts = await reader.ReadPostsAsync(fake_url, DateTime.MinValue);

            posts.Should().NotBeEmpty();
            posts.Should().HaveCount(1);

            var post     = posts.First();
            var expected = new Post
            {
                Author      = "Test",
                Content     = "<p>teste!</p>",
                Date        = new System.DateTime(2018, 3, 9, 14, 0, 26),
                Description = "<p>teste</p>\n",
                Path        = "test",
                Id          = 42,
                Tags        = new[] { "c1", "c2", "c3" },
                Title       = "Teste de post"
            };

            post.Should().BeEquivalentTo(expected);
        }
Exemplo n.º 2
0
        public async Task Should_return_empty_in_a_empty_rss_feed()
        {
            var httpClient = FakeHttpClientFactory.Create(RssData.Empty);
            var reader     = new RssPostReader(httpClient);

            var posts = await reader.ReadPostsAsync(fake_url, DateTime.MinValue);

            posts.Should().BeEmpty();
        }
Exemplo n.º 3
0
        public async Task Should_return_respect_limit_date()
        {
            var httpClient = FakeHttpClientFactory.Create(RssData.OneYerLaterPost, RssData.Default);
            var reader     = new RssPostReader(httpClient);

            var posts = await reader.ReadPostsAsync(fake_url, new DateTime(2019, 1, 1));

            posts.Should().NotBeEmpty();
            posts.Should().HaveCount(1);
            posts.First().Date.Year.Should().Be(2019);
        }