Esempio n. 1
0
        public void Can_fetch_top_stories()
        {
            var topStories = _service.FetchTopStories().Result;

            Assert.IsFalse(string.IsNullOrEmpty(topStories));
            Assert.AreNotEqual(NULLRESPONSE, topStories);
        }
        public IEnumerable <Story> GetNewStories(int count = 500)
        {
            int          storyCount = 0;
            var          json       = _hackerNewsService.FetchTopStories().Result;
            List <int>   storyIds   = _netCoreSerializer.SerializeIntegerList(json).ToList();
            List <Story> retval     = new List <Story>();

            foreach (var id in storyIds)
            {
                var storyJson = _hackerNewsService.FetchItem(id).Result;
                var story     = _netCoreSerializer.Serialize(storyJson);
                if (story != null)
                {
                    retval.Add(story);
                    storyCount++;
                }
                if (storyCount >= count)
                {
                    break;
                }
            }

            return(retval);
        }