public void CleanShoppingCartWithSuccess() { var shopppingCart = new ShoppingCart() { ShoppingCartDevelopers = new List <ShoppingCartDeveloper>() }; shopppingCart.ShoppingCartDevelopers.Add(new ShoppingCartDeveloper() { Username = "******", Price = 100 }); shopppingCart.ShoppingCartDevelopers.Add(new ShoppingCartDeveloper() { Username = "******", Price = 300 }); HttpContext.Current = new HttpContext(new HttpRequest(null, "http://localhost", null), new HttpResponse(null)); HttpContext.Current.Cache[CacheKey] = shopppingCart; ShoppingCartRepository repository = new ShoppingCartRepository(); bool cartCleaned = repository.CleanShoppingCart(); var contextModified = (ShoppingCart)HttpContext.Current.Cache[CacheKey]; Assert.IsTrue(cartCleaned); Assert.AreEqual(0, contextModified.ShoppingCartDevelopers.Count); }
public void CleanEmptyShoppingCartWithoutError() { var shopppingCart = new ShoppingCart() { ShoppingCartDevelopers = new List <ShoppingCartDeveloper>() }; HttpContext.Current = new HttpContext(new HttpRequest(null, "http://localhost", null), new HttpResponse(null)); HttpContext.Current.Cache[CacheKey] = shopppingCart; ShoppingCartRepository repository = new ShoppingCartRepository(); bool cartCleaned = repository.CleanShoppingCart(); var contextModified = (ShoppingCart)HttpContext.Current.Cache[CacheKey]; Assert.IsTrue(cartCleaned); Assert.AreEqual(0, contextModified.ShoppingCartDevelopers.Count); }