Esempio n. 1
0
        public async Task ShouldSortStoredArticleEntities()
        {
            _settingManager.Read().Returns(new Settings {
                Max = 5
            });
            _feedFetchService.Fetch(Arg.Any <string>()).Returns(new List <Article>());
            var channel = new Channel {
                Articles = new List <Article>
                {
                    new Article {
                        Title = "Foo", PublishedDate = DateTime.Now
                    },
                    new Article {
                        Title = "Bar", PublishedDate = DateTime.MinValue
                    },
                    new Article {
                        Title = "Zoo", PublishedDate = DateTime.MaxValue
                    }
                }
            };

            var result = await _feedStoreService.Load(new List <Channel> {
                channel
            });

            var articles = new List <Article>(result);

            articles.Count.Should().Be(3);
            articles[0].Title.Should().Be("Zoo");
            articles[1].Title.Should().Be("Foo");
            articles[2].Title.Should().Be("Bar");
        }
Esempio n. 2
0
        private async Task <Tuple <Channel, IEnumerable <Article> > > FetchAsync(Channel channel, int max)
        {
            var articles = await _feedFetchService.Fetch(channel.Uri).ConfigureAwait(false);

            return(new Tuple <Channel, IEnumerable <Article> >(channel, articles
                                                               .OrderByDescending(i => i.PublishedDate)
                                                               .Take(max)));
        }