public void GetFeed()
        {
            var s = new AccountFeedService(new MockFeedItemService());

            //test for these values of newer then
            foreach (var newerThen in Data.newerThenTests) {

                //test all valid accounts
                foreach (var a in Data.validAccounts) {
                    var af = s.GetFeed(a, newerThen);

                    //get the expected feed items
                    var expectedItems = Data.feeditems[a].Where(i => i.createdAt > newerThen).ToArray();

                    Assert.AreEqual(af.account, a);
                    Assert.AreEqual(af.mentionTotal, expectedItems.Select(i => i.mentions).Sum());
                    Assert.True(af.items.SequenceEqual(expectedItems));
                }
            }
        }
Ejemplo n.º 2
0
        //configure
        /// <summary>
        /// configure app & feeds from config.json
        /// </summary>
        public static void Configure(IConfiguration cfg)
        {
            //app
            daysToShow = Int32.Parse(cfg.Get("app:days_to_show") ?? "0");

            //feeds
            //todo make this more robust
            //hack in feeds:0 as twitter

            var fcfg = cfg.GetConfigurationSection("feeds:0");
            var ocfg = fcfg.GetConfigurationSection("oauth");

            //create OAuthTokenProvider
            var token = new OAuthAppTokenProvider(ocfg.Get("key"), ocfg.Get("secret"), ocfg.Get("app_token_url"), Int32.Parse(ocfg.Get("cache_for_min") ?? "0"));

            //create feed services
            var fiService = new TwitterFeedItemService(new OAuthRequestData(token));
            var aService  = new AccountFeedService(fiService);

            //create twitter feed object and save
            twitterFeed  = new Feed("twitter", fcfg.Get("default_account"),  fcfg.GetArray("default_accounts"), fiService, aService);
        }
        public void GetFeeds()
        {
            var s = new AccountFeedService(new MockFeedItemService());

            //test for these values of newer then
            foreach (var newerThen in Data.newerThenTests) {

                //get account feeds
                var afs = s.GetFeeds(Data.validAccounts, newerThen).ToArray();

                //make sre we got then all
                Assert.True(new HashSet<string>(afs.Select(af => af.account)).SetEquals(Data.validAccounts));

                //test all valid accounts
                foreach (var af in afs) {

                    //get the expected feed items
                    var expectedItems = Data.feeditems[af.account].Where(i => i.createdAt > newerThen).ToArray();

                    Assert.AreEqual(af.mentionTotal, expectedItems.Select(i => i.mentions).Sum());
                    Assert.True(af.items.SequenceEqual(expectedItems));
                }
            }
        }