예제 #1
0
        public void RetrieveItemsForNewFeedStores10Items()
        {
            _repository.GetLatestPublicationDate(_feedUri).Returns((DateTime?)null);
            var feedItems = CreateCollection(10);

            _feedReader.GetMostRecentItems(_feedUri, 10).Returns(feedItems);

            _downloader.RetrieveItems(_feedUri);

            _articleReader.Received(10).GetContent(Arg.Any <Uri>());
            _repository.Received(10).Save(Arg.Any <ISyndicationItem>(), Arg.Any <string>(), _feedUri);
        }
예제 #2
0
        public async Task RetrieveItems(Uri feedUri)
        {
            var latestDate = _itemRepository.GetLatestPublicationDate(feedUri);

            var newItems = latestDate.HasValue ?
                           await _feedReader.GetItemsSince(feedUri, latestDate.Value) :
                           await _feedReader.GetMostRecentItems(feedUri, 10);

            foreach (var item in newItems)
            {
                // I don't know much about RSS, for simplicity I'm assuming there will always
                // be a link in the feed item and the first link will give me the actual article
                var articleUri = item.Links.First().Uri;
                var content    = await _articleReader.GetContent(articleUri);

                _itemRepository.Save(item, content, feedUri);
            }
        }
예제 #3
0
        public void GetLatestPublicationDateForNewFeedReturnsNull()
        {
            var uri = new Uri("http://new.feed/");

            Assert.Null(_repository.GetLatestPublicationDate(uri));
        }