public void LogoutEmptiesCacheRegion()
        {
            var services = new ServiceCollection();

            services.AddMemoryCache();
            var serviceProvider = services.BuildServiceProvider();
            var _cache          = serviceProvider.GetService <IMemoryCache>();

            int       isEmpty;
            Customers test  = new Customers();
            Customers empty = new Customers();

            _cache.Set("loggedInCustomer", test);
            StoreMethods.LogoutCache(_cache);
            if (!_cache.TryGetValue("loggedInCustomer", out empty))
            {
                isEmpty = 1;
            }
            else
            {
                isEmpty = 2;
            }

            //Check that the loggedInCustomer is empty
            Assert.Equal(1, isEmpty);
        }//5
Example #2
0
 /// <summary>
 /// Empties the cache, removes logged in customer
 /// </summary>
 /// <returns></returns>
 public IActionResult Logout()
 {
     StoreMethods.LogoutCache(_cache);
     _logger.LogInformation("User logged out");
     return(View("_Login"));
 }