Example #1
0
 public ViewResult CheckOut(Cart cart, ShippingDetails shippingDetails)
 {
     if (cart.Lines.Count() == 0)
     {
         ModelState.AddModelError("", "Корзина пуста");
     }
     if (ModelState.IsValid)
     {
         orderProcessor.ProcessOrder(cart, shippingDetails);
         cart.Clear();
         return View("Completed");
     }
     else
     {
         return View(shippingDetails);
     }
 }
Example #2
0
        public void Cart_Can_Remove_Lines_And_Clear()
        {
            var productsArray = products.Products.ToArray();
            Cart target = new Cart();
            target.AddItem(productsArray[0], 1);
            target.AddItem(productsArray[1], 2);
            target.AddItem(productsArray[2], 2);
            target.RemoveLine(productsArray[0]);

            var result = target.Lines.ToArray();
            Assert.AreEqual(result.Count(), 2);
            Assert.AreEqual(result[0].Product, productsArray[1]);
            Assert.AreEqual(result[1].Product, productsArray[2]);

            target.Clear();
            result = target.Lines.ToArray();
            Assert.AreEqual(result.Count(), 0);
        }