public void AsyncGetFeedItems()
        {
            var s = new TwitterFeedItemService(new MockRequestData());

            //test all valid accounts
            foreach (var a in Data.validAccounts) {
                var t = s.AsyncGetFeedItems(a);
                t.Wait();
                var items = t.Result;

                //check all items are present
                Assert.True(new HashSet<FeedItem>(items).SetEquals(Data.feeditems[a]));
            }
        }
예제 #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);
        }