public void CalculatePrice_ThreeForTwo_CalculatesCorrectPrice()
        {
            decimal expected = 20.00M;

            var sku = new Sku("3 for 2 Item");

            var threeForTwoPricingRule = new XForYPricingRule(3, 2);

            var threeForTwoItem = new Item(sku, 10.00M, threeForTwoPricingRule);

            decimal actual = threeForTwoItem.CalculatePrice(3);

            Assert.Equal(expected, actual);
        }
        public void CalculatePrice_TwoForOneOnFourItems_CalculatesCorrectPrice()
        {
            decimal expected = 20.00M;

            var sku = new Sku("2 for 1 Item");

            IPricingRule twoForOnePricingRule = new XForYPricingRule(2, 1);

            var twoForOneItem = new Item(sku, 10.00M, twoForOnePricingRule);

            decimal actual = twoForOneItem.CalculatePrice(4);

            Assert.Equal(expected, actual);
        }
        public void Pricing_TwoForOne_CalculatesCorrectPrice()
        {
            decimal expected = 10.00M;

            var sku = new Sku("2 for 1 Item");

            var twoForOnePricingRule = new XForYPricingRule(2, 1);
            var twoForOneItem        = new Item(sku, 10.00M, twoForOnePricingRule);

            var checkout = new Checkout(twoForOneItem);

            checkout.Scan(sku);
            checkout.Scan(sku);

            decimal actual = checkout.CalculateTotal();

            Assert.Equal(expected, actual);
        }
        public void Pricing_ThreeForTwo_CalculatesCorrectPrice()
        {
            decimal expected = 20.00M;

            var sku = new Sku("3 for 2 Item");

            var threeForTwoPricingRule = new XForYPricingRule(3, 2);

            var threeForTwoItem = new Item(sku, 10.00M, threeForTwoPricingRule);

            var checkout = new Checkout(threeForTwoItem);

            checkout.Scan(sku);
            checkout.Scan(sku);
            checkout.Scan(sku);

            decimal actual = checkout.CalculateTotal();

            Assert.Equal(expected, actual);
        }
Beispiel #5
0
        public void Calculate_NegativeCount_Throws()
        {
            var pricingRule = new XForYPricingRule("productId", 1.0m, 3, 2);

            pricingRule.Invoking(pr => pr.Calculate(-1)).Should().Throw <ArgumentException>();
        }
Beispiel #6
0
        public void CalculateTests(decimal price, int x, int y, int count, decimal total)
        {
            var pricingRule = new XForYPricingRule("productId", price, x, y);

            pricingRule.Calculate(count).Should().Be(total);
        }