示例#1
0
        public void GetTotalCartPrice_IfOfferIsNotApplied_OnAllProduct_ReturnAmountWithUnDiscountedPrice()
        {
            double           expectedValue = 458.90;
            IShoppingCatalog Catalog       = new FakeCatalog();

            Catalog.AddProduct(RubberGloves, 59.90);
            Catalog.AddProduct(Stethoscope, 399);

            ShoppingCart cart = new ShoppingCart();

            cart.AddLine(new OrderLine(RubberGloves, 1));
            cart.AddLine(new OrderLine(Stethoscope, 1));

            var order   = new Order(Catalog);
            var receipt = order.ChecksOutGoods(cart);

            double actaulValue = receipt.GetTotalPrice();

            Assert.AreEqual(expectedValue, actaulValue);
        }
示例#2
0
        public void GetTotalCartPrice_IfOfferValid_And_SeveralOrderLineOfSameCode_ForStethoscope_ReturnAmountWithDiscountedPrice()
        {
            double           expectedValue = 10389;
            IShoppingCatalog Catalog       = new FakeCatalog();

            Catalog.AddProduct(Stethoscope, 399);

            ShoppingCart cart = new ShoppingCart();

            cart.AddLine(new OrderLine(Stethoscope, 27));
            cart.AddLine(new OrderLine(Stethoscope, 4));

            var order = new Order(Catalog);

            order.AddSpecialOffer(SpecialOfferType.ThreeForAmount, Stethoscope);
            var receipt = order.ChecksOutGoods(cart);

            double actaulValue = receipt.GetTotalPrice();

            Assert.AreEqual(expectedValue, actaulValue);
        }
示例#3
0
        public void GetTotalCartPrice_WithValidOffer_And_SeveralOrderLineOfSameCode_ForRubberGloves_ReturnAmountWithDiscountedPrice()
        {
            double           expectedValue = 119.80;
            IShoppingCatalog Catalog       = new FakeCatalog();

            Catalog.AddProduct(RubberGloves, 59.90);

            ShoppingCart cart = new ShoppingCart();

            cart.AddLine(new OrderLine(RubberGloves, 1));
            cart.AddLine(new OrderLine(RubberGloves, 1));
            cart.AddLine(new OrderLine(RubberGloves, 1));

            var order = new Order(Catalog);

            order.AddSpecialOffer(SpecialOfferType.ThreeForTwo, RubberGloves);
            var receipt = order.ChecksOutGoods(cart);

            double actaulValue = receipt.GetTotalPrice();

            Assert.AreEqual(expectedValue, actaulValue);
        }
示例#4
0
        public void GetTotalCartPrice_IfOfferOnStethoscope_ReturnAmountWithDiscountPrice()
        {
            double           expectedValue = 1179.745;
            IShoppingCatalog Catalog       = new FakeCatalog();

            Catalog.AddProduct(Talc, 19.54);
            Catalog.AddProduct(Stethoscope, 19.54);

            ShoppingCart cart = new ShoppingCart();

            cart.AddLine(new OrderLine(Stethoscope, 3));
            cart.AddLine(new OrderLine(Talc, 9.25));

            var order = new Order(Catalog);

            order.AddSpecialOffer(SpecialOfferType.ThreeForAmount, Stethoscope);
            var receipt = order.ChecksOutGoods(cart);

            double actaulValue = receipt.GetTotalPrice();

            Assert.AreEqual(expectedValue, actaulValue);
        }
示例#5
0
        public void GetTotalCartPrice_IfOfferOnRubberGloves_ReturnAmountWithDiscountPrice()
        {
            double           expectedValue = 315.2;
            IShoppingCatalog Catalog       = new FakeCatalog();

            Catalog.AddProduct(RubberGloves, 59.90);
            Catalog.AddProduct(Talc, 19.54);

            ShoppingCart cart = new ShoppingCart();

            cart.AddLine(new OrderLine(RubberGloves, 3));
            cart.AddLine(new OrderLine(Talc, 10));

            var order = new Order(Catalog);

            order.AddSpecialOffer(SpecialOfferType.ThreeForTwo, RubberGloves);
            var receipt = order.ChecksOutGoods(cart);

            double actaulValue = receipt.GetTotalPrice();

            Assert.AreEqual(expectedValue, actaulValue);
        }
示例#6
0
        public void GetTotalCartPrice_IfOfferIsApplied_SingleProduct_ReturnAmountWithDiscountedPriceForOneProdcuctInCart()
        {
            double           expectedValue = 2177.70;
            IShoppingCatalog Catalog       = new FakeCatalog();

            Catalog.AddProduct(RubberGloves, 59.90);
            Catalog.AddProduct(Stethoscope, 399);

            ShoppingCart cart = new ShoppingCart();

            cart.AddLine(new OrderLine(RubberGloves, 3));
            cart.AddLine(new OrderLine(Stethoscope, 6));

            var order = new Order(Catalog);

            order.AddSpecialOffer(SpecialOfferType.ThreeForAmount, Stethoscope);
            var receipt = order.ChecksOutGoods(cart);

            double actaulValue = receipt.GetTotalPrice();

            Assert.AreEqual(expectedValue, actaulValue);
        }
示例#7
0
        public void ProductIsNotInCatalog_ReturnKeyNotFoundException()
        {
            IShoppingCatalog Catalog = new FakeCatalog();

            Catalog.AddProduct(RubberGloves, 399);
            Catalog.AddProduct(Talc, 399);

            ShoppingCart cart = new ShoppingCart();

            cart.AddLine(new OrderLine(Stethoscope, 1));

            var order = new Order(Catalog);

            Assert.Throws <KeyNotFoundException>(() => order.ChecksOutGoods(cart));
        }
示例#8
0
        public void GetTotalCartPrice_NotInOffer_ForTalc_ReturnAmountWihtUndiscountPrice(double weight, double expectedValue)
        {
            IShoppingCatalog Catalog = new FakeCatalog();

            Catalog.AddProduct(Talc, 19.54);

            ShoppingCart cart = new ShoppingCart();

            cart.AddLine(new OrderLine(Talc, weight));

            var order   = new Order(Catalog);
            var receipt = order.ChecksOutGoods(cart);

            double actaulValue = receipt.GetTotalPrice();

            Assert.AreEqual(expectedValue, actaulValue);
        }
示例#9
0
        public void GetTotalCartPrice_IfOfferIsNotAppliedOnValidQuantity_OfStethoscope_ReturnAmountWithUnDiscountedPrice()
        {
            double           expectedValue = 1197;
            IShoppingCatalog Catalog       = new FakeCatalog();

            Catalog.AddProduct(Stethoscope, 399);

            ShoppingCart cart = new ShoppingCart();

            cart.AddLine(new OrderLine(Stethoscope, 3));

            var order   = new Order(Catalog);
            var receipt = order.ChecksOutGoods(cart);

            double actaulValue = receipt.GetTotalPrice();

            Assert.AreEqual(expectedValue, actaulValue);
        }
示例#10
0
        public void GetTotalCartPrice_IfOfferNotValidOnQunatity_ForOnePairRubberGloves_ReturnAmountWithDicountedPrice()
        {
            double           expectedValue = 59.90;
            IShoppingCatalog Catalog       = new FakeCatalog();

            Catalog.AddProduct(RubberGloves, 59.90);

            ShoppingCart cart = new ShoppingCart();

            cart.AddLine(new OrderLine(RubberGloves, 1));

            var order   = new Order(Catalog);
            var receipt = order.ChecksOutGoods(cart);

            double actaulValue = receipt.GetTotalPrice();

            Assert.AreEqual(expectedValue, actaulValue);
        }
示例#11
0
        public void GetTotalCartPrice_IfOfferNotValidOnQunatity_ForStethoscope_ReturnAmountWithUnDicountedPrice(int quantity, double expectedValue)
        {
            IShoppingCatalog Catalog = new FakeCatalog();

            Catalog.AddProduct(Stethoscope, 399);

            ShoppingCart cart = new ShoppingCart();

            cart.AddLine(new OrderLine(Stethoscope, quantity));

            var order = new Order(Catalog);

            order.AddSpecialOffer(SpecialOfferType.ThreeForAmount, Stethoscope);
            var receipt = order.ChecksOutGoods(cart);

            double actaulValue = receipt.GetTotalPrice();

            Assert.AreEqual(expectedValue, actaulValue);
        }
示例#12
0
        public void GetTotalCartPrice_OfferNotValidOnProduct_ReturnAmountWithUnDiscountedPrice(SpecialOfferType specialOfferType)
        {
            double           expectedValue = 29.31;
            IShoppingCatalog Catalog       = new FakeCatalog();

            Catalog.AddProduct(Talc, 19.54);

            ShoppingCart cart = new ShoppingCart();

            cart.AddLine(new OrderLine(Talc, 1.5));

            var order = new Order(Catalog);

            order.AddSpecialOffer(specialOfferType, Talc);
            var receipt = order.ChecksOutGoods(cart);

            double actaulValue = receipt.GetTotalPrice();

            Assert.AreEqual(expectedValue, actaulValue);
        }
示例#13
0
        public void GetTotalCartPrice_IfInValidProductOffer_Stethoscope_ReturnAmountWithUnDiscountedPrice()
        {
            double           expectedValue = 1197;
            IShoppingCatalog Catalog       = new FakeCatalog();

            Catalog.AddProduct(Stethoscope, 399);

            ShoppingCart cart = new ShoppingCart();

            cart.AddLine(new OrderLine(Stethoscope, 3));

            var order = new Order(Catalog);

            order.AddSpecialOffer(SpecialOfferType.ThreeForAmount, RubberGloves);
            var receipt = order.ChecksOutGoods(cart);

            double actaulValue = receipt.GetTotalPrice();

            Assert.AreEqual(expectedValue, actaulValue);
        }