Exemple #1
0
        public void CheckoutCart_LessThan200_DefaultShippingCost()
        {
            var store = new OnlineStore(new Catalog());

            store.CreateShoppingCart(CustomerName);
            // 11*1 = 11kg overweight, $25 overweight charge applies
            store.AddItemToShoppingCart(CustomerName, ProductTypeEnum.Stove, 3); //$120

            Assert.AreEqual(3, store.GetItemCountInCart(CustomerName, ProductTypeEnum.Stove));
            Assert.AreEqual(120M + 20M, store.CheckoutShoppingCart(CustomerName)); // price = $120+$20
        }
Exemple #2
0
        public void CheckoutCart_Over200_Overweight()
        {
            var store = new OnlineStore(new Catalog());

            store.CreateShoppingCart(CustomerName);
            // 11*1 = 11kg overweight, $25 overweight charge applies
            store.AddItemToShoppingCart(CustomerName, ProductTypeEnum.Stove, 11);

            Assert.AreEqual(11, store.GetItemCountInCart(CustomerName, ProductTypeEnum.Stove));
            Assert.AreEqual(465M, store.CheckoutShoppingCart(CustomerName)); // price = 11*40 + 25
        }
Exemple #3
0
        public void CheckoutCart_Over200_WaiveShippingCost_OverweightNotApply()
        {
            var          store        = new OnlineStore(new Catalog());
            const string customerName = CustomerName;

            store.CreateShoppingCart(customerName);
            // 6*1 = 6kg not overweight, $25 overweight charge not appluy
            store.AddItemToShoppingCart(customerName, ProductTypeEnum.Stove, 6); //$240

            Assert.AreEqual(6, store.GetItemCountInCart(customerName, ProductTypeEnum.Stove));
            Assert.AreEqual(240M, store.CheckoutShoppingCart(customerName)); // price = $240
        }
Exemple #4
0
        public void CheckoutCart_LessThan200_Overweight()
        {
            var store = new OnlineStore(new Catalog());

            store.CreateShoppingCart(CustomerName);
            // 11*1 = 11kg overweight, $25 overweight charge applies, price is $55, less than $200
            store.AddItemToShoppingCart(CustomerName, ProductTypeEnum.DehydratedMeal, 11);

            Assert.AreEqual(11, store.GetItemCountInCart(CustomerName, ProductTypeEnum.DehydratedMeal));
            Assert.AreEqual(55M + 25M + 20M,
                            store.CheckoutShoppingCart(CustomerName)); // price = 11*5 + $25 OW+ $20 Default Charge
        }
Exemple #5
0
        public void CheckoutCart_Over3Tents_15PercentDiscount()
        {
            var          store        = new OnlineStore(new Catalog());
            const string customerName = CustomerName;

            store.CreateShoppingCart(customerName);

            store.AddItemToShoppingCart(customerName, ProductTypeEnum.Tent, 5);            //$5*$50
            store.AddItemToShoppingCart(customerName, ProductTypeEnum.DehydratedMeal, 10); //10*5

            Assert.AreEqual(5, store.GetItemCountInCart(customerName, ProductTypeEnum.Tent));
            Assert.AreEqual(10, store.GetItemCountInCart(customerName, ProductTypeEnum.DehydratedMeal));
            // price = 5*$50 + $25 + $5*10
            // 5*2.5 = 12.5kg 'overweight, $25 overweight charge apply
            Assert.AreEqual((5 * 50M + 10 * 5M) * .85M + 25M, store.CheckoutShoppingCart(customerName));
        }
Exemple #6
0
        public void CheckoutCart_Detailed()
        {
            var          store        = new OnlineStore(new Catalog());
            const string customerName = CustomerName;

            store.CreateShoppingCart(customerName);
            // 11*1 = 11kg overweight, $25 overweight charge applies
            store.AddItemToShoppingCart(customerName, ProductTypeEnum.Stove, 3); //$120

            Assert.AreEqual(3, store.GetItemCountInCart(customerName, ProductTypeEnum.Stove));
            var shoppingCart = store.CheckoutShoppingCart(customerName, true);

            Assert.AreEqual(120, shoppingCart.SubTotal);
            Assert.AreEqual(20, shoppingCart.ShippingFees);
            Assert.AreEqual(140, shoppingCart.Total);
            Assert.AreEqual(0, shoppingCart.Discounts);
        }