Ejemplo n.º 1
0
        public async Task RssService_FetchesFeedAsync_WrongUrl_FeedItemsListIsEmpty()
        {
            var service = new RssService(_rssHttpClientFactory);

            var feedItems = await service.FetchFeedAsync("www.rongurl.nope");

            Assert.IsEmpty(feedItems);
        }
Ejemplo n.º 2
0
        public async Task RssService_FetchesFeedAsync_FeedItemsListHasEntries()
        {
            var expectedNumberOfItems = 2;
            var service = new RssService(_rssHttpClientFactory);

            var document = new XDocument();
            var xElement = new XElement("channel");

            document.Add(xElement);
            xElement.Add(
                CreateRssEntry("RSSTitle", "*****@*****.**", "a useful description", "Fri, 06 Apr 2018 12:51:01 +0000"),
                CreateRssEntry("RSSTitle", "*****@*****.**", "a useful description", "Fri, 06 Apr 2018 12:51:01 +0000")
                );

            _httpClient.GetStringAsync(Arg.Any <string>()).Returns(document.ToString());
            _rssHttpClientFactory.CreateHttpClient().Returns(_httpClient);

            var feedItems = await service.FetchFeedAsync(Urls.RssFeedUrl);

            Assert.IsNotEmpty(feedItems);
            Assert.AreEqual(expectedNumberOfItems, feedItems.Count);
        }