public ActionResult AddProductsToShoppingBasket(int?ProductId) { int? ClientId = HttpContext.Session.GetInt32("ClientId"); AdminLogic admin = new AdminLogic(); List <Product> allproducts = admin.GetAllProducts(); ShoppingBasketLogic Basket = new ShoppingBasketLogic(); ClientLogic clientlogic = new ClientLogic(); // /ShoppingBasket/AddProductsToShoppingBasket/ProductId?=1?Clientid=5 foreach (Product p in allproducts) { if (ProductId == p.ProductId) { clientlogic.AddProductToShoppingBasket(Convert.ToInt32(ClientId), Convert.ToInt32(ProductId)); } } //Client.AddProductsToShoppingBasket(product); return(RedirectToAction("HomeClient", "Home")); }
public void AddProductToShoppingBasket_addproduct_productadded() { //Arrange int count; int countAfterAdding; int expect; int clientid = 3039; // Name of Client: sam int Productid = 12; // Name of produt :Enzoknol phone cover ClientLogic clientlogic = new ClientLogic(); //Act count = clientlogic.GetShoppinBasketCount(); clientlogic.AddProductToShoppingBasket(clientid, Productid); expect = count + 1; countAfterAdding = clientlogic.GetShoppinBasketCount(); //Assert Assert.Equal(expect, countAfterAdding); }