public void returns_feed_mixed_from_cached()
        {
            var config = _configurationProvider.ProvideConfig();

            var feeds = Resource.read_feeds().ToList();

            add_feed_to_db(config.SourceFeeds[0], feeds[0]);
            add_feed_to_db(config.SourceFeeds[1], feeds[1]);

            var mixedItems = new[]
            {
                new SyndicationItem(), new SyndicationItem(),
            };

            A.CallTo(
                () => _feedMixer.MixFeeds(
                    A <string[]> .That.IsSameSequenceAs(feeds)
                    )
                ).Returns(mixedItems);

            var result = execute();

            Assert.Equal(mixedItems, result.Items.ToArray());
        }
Exemple #2
0
        public SyndicationFeed ComposeFeed()
        {
            dynamic db   = _localFeedsProvider.Db();
            dynamic view = GetLocalFeedInfoView(db);

            List <LocalFeedInfo> allFeeds = view.All()
                                            .ToList <LocalFeedInfo>();

            var feedsArray = allFeeds
                             .Where(x => _config.SourceFeeds.Contains(x.Url))
                             .Select(x => x.Content).ToArray();

            var items = _feedMixer.MixFeeds(feedsArray);

            var feed = new SyndicationFeed(items.Take(_config.MaxItems));

            feed.Title           = new TextSyndicationContent(_config.Title);
            feed.LastUpdatedTime = ApplicationTime.Current;

            _log.Debug("Composed result feed '{0}' with {1} items coming from {2} source feeds", feed.Title, feed.Items.Count(), feedsArray.Length);

            return(feed);
        }