Пример #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);
        }
Пример #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);
        }
Пример #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));
        }
Пример #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));
        }
Пример #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);
        }
Пример #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);
        }