Esempio n. 1
0
        public void ParseInvalidRssFeed_ShouldThrow()
        {
            var feedMock = new SyndicationFeed {
                Title = new TextSyndicationContent("test", TextSyndicationContentKind.Plaintext), BaseUri = new Uri("//testUri.com")
            };

            feedMock.Items = new List <SyndicationItem> {
                mockSyndicationItem("title", "audio/mpeg", "incorrectInput", "//episodeuri.test.com", 111111)
            };
            _rssFeedRepo.Setup(x => x.CallRssFeed("test")).Returns(feedMock);

            var service = new RssFeedService(_rssFeedRepo.Object);

            Assert.Throws <InvalidOperationException>(() => { service.GetRssFeed("test"); });
        }
Esempio n. 2
0
        public List <RssWithUrl> GetNonDuplicatePosts()
        {
            var posts     = wpClient.GetPosts();
            var feeditems = rssFeed.GetRssFeed();

            var latestPost = posts.OrderByDescending(item => item.PublishDateTime).FirstOrDefault();

            if (latestPost != null)
            {
                feeditems =
                    feeditems.Where(feeditem => DateTime.Parse(feeditem.PubDate) > latestPost.PublishDateTime)
                    .ToList();
            }
            var postsToAdd = PostsFromReadability(feeditems);

            // if not null, order from earliest to latest in case updating fails in the middle
            postsToAdd = postsToAdd?.OrderBy(post => DateTime.Parse(post.RssModel.PubDate)).ToList();
            return(postsToAdd);
        }
Esempio n. 3
0
        public void ParseValidRssFeed_ShouldReturnValidObject()
        {
            var feedMock = new SyndicationFeed {
                Title = new TextSyndicationContent("test", TextSyndicationContentKind.Plaintext), BaseUri = new Uri("//testUri.com")
            };

            feedMock.Items = new List <SyndicationItem> {
                mockSyndicationItem("title", "audio/mpeg", "alternate", "//episodeuri.test.com", 111111),
                mockSyndicationItem("title", "audio/mpeg", "alternate", "//episodeuri.test.com", 222222),
                mockSyndicationItem("title", "audio/mpeg", "alternate", "//episodeuri.test.com", 333333),
                mockSyndicationItem("title", "audio/mpeg", "alternate", "//episodeuri.test.com", 444444)
            };
            _rssFeedRepo.Setup(x => x.CallRssFeed("test")).Returns(feedMock);

            var service = new RssFeedService(_rssFeedRepo.Object);

            var result = service.GetRssFeed("test");

            Assert.NotNull(result[0].Url);
            Assert.NotNull(result[1].Url);
            Assert.NotNull(result[2].Url);
            Assert.NotNull(result[3].Url);
        }