Ejemplo n.º 1
0
        public async Task <IActionResult> StopHangfire()
        {
            APIInteraction api = new APIInteraction(config);

            await api.StopHangfire();

            return(RedirectToAction("Beheerder", "Account"));
        }
        /*
         *  Entry method for index view.
         *  1. Build list of best stories
         *  2. Cache results
         *
         */
        public ActionResult Index()
        {
            ObjectCache  cache   = MemoryCache.Default;
            List <Story> stories = cache["bestStories"] as List <Story>;

            if (stories == null)
            {
                CacheItemPolicy policy = new CacheItemPolicy
                {
                    AbsoluteExpiration = DateTimeOffset.Now.AddMinutes(10.0),
                };

                stories = APIInteraction.GetStoryList();
                cache.Set("bestStories", stories, policy);
            }

            return(View(stories));
        }
Ejemplo n.º 3
0
        public async Task GetStoryTest()
        {
            List <Story>         stories       = new List <Story>();
            List <Task <Story> > allStoryTasks = new List <Task <Story> >();
            Task <List <int> >   bestStories   = Task.Run(async() => await APIInteraction.GetBestStories());

            var storiesList = bestStories.Result;

            allStoryTasks.Add(Task.Run(async() => await APIInteraction.GetStory(storiesList[0])));

            var continuation = Task.WhenAll(allStoryTasks);

            for (int i = 0; i <= continuation.Result.Length - 1; i++)
            {
                stories.Add(continuation.Result[i]);
            }

            Assert.IsNotNull(stories);
        }
Ejemplo n.º 4
0
        public async Task GetBestStoriesTest()
        {
            var result = await APIInteraction.GetBestStories();

            Assert.IsNotNull(result);
        }