public void CartCheckoutWithOneItem_Succeeds()
 {
     var line = new OrderLine(new Wine());
     cart.AddLineToCart(line);
     cart.CheckOut();
     Assert.AreEqual(1, cart.TotalItems);
 }
Beispiel #2
0
        public void AddLineToCart(OrderLine line)
        {
            if (!line.IsWineInStock)
                throw new InvalidOperationException("Wine is not in out stock.");

            if (line.Quantity <= 0)
                throw new InvalidOperationException(string.Format("Invalid Quantity: {0}", line.Quantity));

            linesToProcess.Add(line);
        }
        public void CartAddLessOrZeroQuantityElements_Fails(int lessQuantity)
        {
            var wineToBuy = new Wine { Name = "Great red wine" };
            var line = new OrderLine(wineToBuy)
            {
                Quantity = lessQuantity,
                Price = 10
            };

            Assert.Throws<InvalidOperationException>(() => cart.AddLineToCart(line));
        }
 public void CartCheckoutPriceOK_OneLine()
 {
     var wineToBuy = new Wine { Name = "Great red wine" };
     var line = new OrderLine(wineToBuy)
                    {
                        Quantity = 5,
                        Price = 50
                    };
     cart.AddLineToCart(line);
     cart.CheckOut();
     Assert.AreEqual(250, cart.TotalPrice);
 }
 public void CartCheckout_NoWinesInStock_Fauls()
 {
     var line = new OrderLine(new Wine() { InStock = false });
     Assert.Throws<InvalidOperationException>(() => cart.AddLineToCart(line));
 }
 public void OrderLineCration_HasSingleQuantity()
 {
     var line = new OrderLine(new Wine());
     Assert.AreEqual(1, line.Quantity);
 }