Ejemplo n.º 1
0
        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]);
        }
Ejemplo n.º 2
0
        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]);
        }
Ejemplo n.º 3
0
 /// <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);
     }
 }