public async Task updateProductInCartSuccess() { string username = marketUsers.AddGuest(); User u = marketUsers.GetUserByUserName(username); Result <Product> result = await MarketStores.Instance.AddProduct(product1, store.Id, "founder"); ShoppingBasket b = await u.ShoppingCart.GetShoppingBasket(store); await b.addProduct(result.Ret, 4); Assert.AreEqual("product updated", marketUsers.ChangeProductQuanInCart(username, result.Ret.Id, 5)); Assert.IsTrue(b.GetProducts().Contains(result.Ret)); Assert.AreEqual(b.GetProductQuantity(result.Ret), 5); }
public async Task updateProductInCartSuccess() { string username = m.AddGuest(); User u = m.GetUserByUserName(username); Product p = new Product(new Guid(), "lala8", 8, 50, 500, "category"); Store s = new Store("lalali80", null, null); s.Products.Add(p); marketStores.LoadedStores.TryAdd(s.GetId(), s); ShoppingBasket b = await u.ShoppingCart.GetShoppingBasket(s); await b.addProduct(p, 4); Assert.AreEqual("product updated", m.ChangeProductQuanInCart(username, p.Id, 5)); Assert.IsTrue(b.GetProducts().Contains(p)); Assert.AreEqual(b.GetProductQuantity(p), 5); }
public void updateProductInCartSuccess() { ProxyMarketContext.Instance.IsDebug = true; string username = m.AddGuest(); User u = m.GetUserByUserName(username); Mock <ShoppingCart> cart = new Mock <ShoppingCart>(); Mock <ShoppingBasket> bask = new Mock <ShoppingBasket>(); cart.Setup(c => c.TryGetShoppingBasket(It.IsAny <Store>())).Returns(bask.Object); bask.Setup(b => b.TryUpdateProduct(It.IsAny <Product>(), It.IsAny <int>())).Returns(true); u.ShoppingCart = cart.Object; Product p = new Product(new Guid(), "lala8", 8, 50, 500, "category"); Store s = new Store("lalali80", null, null); s.Products.Add(p); marketStores.LoadedStores.TryAdd(s.GetId(), s); Assert.AreEqual("product updated", m.ChangeProductQuanInCart(username, p.Id, 5)); }