public void TestSubmitOrder() { var userId = Guid.NewGuid(); Product q = new Product(); Cart cart = new Cart(userId); cart.AddProduct(q, 7); Order order = new Order(userId, cart.Items); Assert.AreEqual(7, order.Items[q.Id]); }
public void TestAddProduct() { var userId = Guid.NewGuid(); Product p = new Product(); Cart cart = new Cart(userId); cart.AddProduct(p, 10); Assert.AreEqual(10, cart.Items[p.Id]); }
/// <summary> /// Adds an item to the cart /// </summary> /// <param name="product">The product type to be added to the cart</param> /// <param name="quantity">quantity of products to be added</param> public void AddProduct(Product product, int quantity) { if (Items.ContainsKey(product.Id)) { Items[product.Id] += quantity; } else { Items.Add(product.Id, quantity); } }