public static PostsRepository Create() { var client = new HttpClient(); var reader = new RssPostReader(client); return(new PostsRepository(reader, Config.LimitDate, Config.FeedUrl)); }
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); }
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(); }
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); }