public void HandleDiscountForItemB()
        {
            QuantityBasedDiscount quantityBasedDiscount = new QuantityBasedDiscount();

            Cart cart = new Cart();

            cart.Items = new List <CartItem>();
            cart.Items.Add(new CartItem()
            {
                Quantity    = 2,
                ProductInfo = new ProductInfo("B", 30)
            });

            quantityBasedDiscount.HandleDiscount(cart);
            Assert.AreEqual(45, cart.TotalPrice);
        }
        public void HandleDiscountForFiveItemA()
        {
            QuantityBasedDiscount quantityBasedDiscount = new QuantityBasedDiscount();

            Cart cart = new Cart();

            cart.Items = new List <CartItem>();
            cart.Items.Add(new CartItem()
            {
                Quantity    = 5,
                ProductInfo = new ProductInfo("A", 50)
            });

            quantityBasedDiscount.HandleDiscount(cart);
            Assert.AreEqual(230, cart.TotalPrice);
        }
        public void HandleDiscountForNegativeFiveItemA()
        {
            QuantityBasedDiscount quantityBasedDiscount = new QuantityBasedDiscount();

            Cart cart = new Cart();

            cart.Items = new List <CartItem>();
            cart.Items.Add(new CartItem()
            {
                Quantity    = -5,
                ProductInfo = new ProductInfo("A", 50)
            });

            quantityBasedDiscount.HandleDiscount(cart);

            // handle negative price before applying promotion
            Assert.AreEqual(-250, cart.TotalPrice);
        }
        public void QuantityBasedDiscount_ShouldNotFailForEmptyCart()
        {
            QuantityBasedDiscount quantityBasedDiscount = new QuantityBasedDiscount();

            quantityBasedDiscount.HandleDiscount(new Cart());
        }
        public void QuantityBasedDiscount_ShouldNotFailForNull()
        {
            QuantityBasedDiscount quantityBasedDiscount = new QuantityBasedDiscount();

            quantityBasedDiscount.HandleDiscount(null);
        }