Example #1
0
        public async Task GetBestStories_Should_Return_List_Of_Articles()
        {
            init();
            HackerNewsService service = new HackerNewsService(_mockRepo.Object);

            var articles = await service.GetBestStories();

            articles.Should().HaveCount(2);
        }
Example #2
0
        public async Task <IActionResult> GetTwentyBestStories([FromServices] IMemoryCache cache)
        {
            var stories = await _service.GetBestStories(20, cache);

            if (stories.Any())
            {
                return(Ok(stories));
            }
            return(NotFound());
        }
Example #3
0
        public async Task <List <BestStoriesModel> > getBestStories()
        {
            // Init the search text to empty
            ViewBag.newsSearchText = "";
            // Get all the best stories
            var bestStoriesIDs = await HackerNewsService.GetBestStoriesIDs(appSettings);

            var bestStories = await HackerNewsService.GetBestStories(bestStoriesIDs, appSettings);

            return(bestStories.OrderByDescending(i => i.time).Take(20).ToList());
        }