Example #1
0
        public void AddToCartDoesNotDuplicateCartItems()
        {
            //Arrange
            var cart = new ShoppingCart();

            //Act
            cart.ClearCart();
            cart.AddDrink(PricyDrink);
            cart.AddDrink(PricyDrink);
            //Assert
            Assert.AreEqual(cart.GetItems().Count(), 1);
            Assert.AreEqual(cart.GetItems().Select(i => i.Quantity).Sum(), 2);
        }
Example #2
0
        public void CheckTotal()
        {
            //Arrange
            var     cart  = new ShoppingCart();
            decimal total = 12.1M;

            //Act
            cart.ClearCart();
            cart.AddDrink(PricyDrink);
            cart.AddDrink(CheapDrink);
            cart.AddDrink(CheapDrink);
            //Assert
            Assert.AreEqual(cart.Total, total);
        }
Example #3
0
        public void TestAllowedPayment_IncludesCash()
        {
            //Arrange
            var cart = new ShoppingCart();

            //Act
            cart.ClearCart();
            cart.AddDrink(CheapDrink);
            //Assert
            Assert.IsTrue(cart.GetAllowedPayments().Contains(PaymentType.Cash));
            Assert.IsTrue(cart.GetAllowedPayments().Contains(PaymentType.CreditCard));
        }
Example #4
0
        public void TestAllowedPayment_OnlyCC()
        {
            //Arrange
            var cart = new ShoppingCart();

            //Act
            cart.ClearCart();
            cart.AddDrink(PricyDrink);
            //Assert
            Assert.IsFalse(cart.GetAllowedPayments().Contains(PaymentType.Cash));
            Assert.IsTrue(cart.GetAllowedPayments().Contains(PaymentType.CreditCard));
        }
Example #5
0
        public void DiscountALLFREEApplyed()
        {
            //Arrange
            var cart  = new ShoppingCart();
            var total = 0M;

            //Act
            cart.ClearCart();
            cart.AddDrink(PricyDrink);
            cart.ApplyDiscount(DiscountCodes.ALLFREE);
            //Assert
            Assert.AreEqual(cart.Total, total);
            Assert.AreEqual(cart.Discount, 1M);
        }
Example #6
0
        public void Discount50Applyed()
        {
            //Arrange
            var cart  = new ShoppingCart();
            var total = 10.1M * (1 - 0.5M);

            //Act
            cart.ClearCart();
            cart.AddDrink(PricyDrink);
            cart.ApplyDiscount(DiscountCodes.DISCOUNT50);
            //Assert
            Assert.AreEqual(cart.Total, total);
            Assert.AreEqual(cart.Discount, 0.5M);
        }