Ejemplo n.º 1
0
        public void DiscountIsZeroWhenNoButterAndOneBread()
        {
            LinkedDiscountCalculator breadAndButterDiscount = new LinkedDiscountCalculator(butter, bread, 2, 1, 0.5f);

            Dictionary <Product, int> oneBreadNoButter = new Dictionary <Product, int>
            {
                { bread, 1 },
            };

            decimal discount = breadAndButterDiscount.CalculateDiscount(oneBreadNoButter);

            decimal expectedDiscount = 0;

            Assert.AreEqual(expectedDiscount, discount);
        }
Ejemplo n.º 2
0
        public void DiscountIsOneBreadWhenTwoButterAndThreeBreadFor231()
        {
            LinkedDiscountCalculator breadAndButterDiscount = new LinkedDiscountCalculator(butter, bread, 2, 3, 1);

            Dictionary <Product, int> fourBreadTwoButter = new Dictionary <Product, int>
            {
                { bread, 3 },
                { butter, 2 }
            };

            decimal discount = breadAndButterDiscount.CalculateDiscount(fourBreadTwoButter);

            decimal expectedDiscount = bread.Cost;

            Assert.AreEqual(expectedDiscount, discount);
        }
Ejemplo n.º 3
0
        public void DiscountIsHalfBreadWhenTwoButterAndFourBread()
        {
            LinkedDiscountCalculator breadAndButterDiscount = new LinkedDiscountCalculator(butter, bread, 2, 1, 0.5f);

            Dictionary <Product, int> fourBreadTwoButter = new Dictionary <Product, int>
            {
                { bread, 4 },
                { butter, 2 }
            };

            decimal discount = breadAndButterDiscount.CalculateDiscount(fourBreadTwoButter);

            decimal expectedDiscount = bread.Cost * 0.5m;

            Assert.AreEqual(expectedDiscount, discount);
        }
Ejemplo n.º 4
0
 public void CanNotCreateLinkedCalculatorWithNoDiscountProducts()
 {
     LinkedDiscountCalculator breadAndButterDiscount = new LinkedDiscountCalculator(butter, bread, 2, 0, 0.5f);
 }