Ejemplo n.º 1
0
        public void CalculateSingleTax_WithImportTaxAndExemptTaxAndRoundingRule_CalculatesTaxValue()
        {
            //arrange
            double             price       = 100.99;
            ShoppingBasketItem item        = new ShoppingBasketItem(new Product("test", price, ProductType.Food), true);
            double             expectedTax = (new RoundingTaxRule().ApplyTaxRule(new ExemptSalesTaxRate().CalculateTax(price))) + (new RoundingTaxRule().ApplyTaxRule(new ImportSalesTaxRate().CalculateTax(price)));

            //act
            double actualTax = item.CalculateSingleItemTax();

            //assert
            Assert.AreEqual(expectedTax, actualTax, "Single item tax incorrectly calculated for item with import and exempt tax rate");
        }
Ejemplo n.º 2
0
        public void CalculateSingleTax_WithBasicTaxAndRoundingRule_CalculatesTaxValue()
        {
            //arrange
            double             price       = 1.5;
            ShoppingBasketItem item        = new ShoppingBasketItem(new Product("test", price));
            double             expectedTax = new RoundingTaxRule().ApplyTaxRule(new BasicSalesTaxRate().CalculateTax(price));

            //act
            double actualTax = item.CalculateSingleItemTax();

            //assert
            Assert.AreEqual(expectedTax, actualTax, "Single item tax incorrectly calculated for item with basic tax rate");
        }
Ejemplo n.º 3
0
        public void CalculateTotalTax_WithMultipleItems_CalculatesTaxValue()
        {
            //arrange
            double             price       = 45.35;
            int                quantity    = 4;
            ShoppingBasketItem item        = new ShoppingBasketItem(new Product("test", price), quantity);
            double             expectedTax = item.CalculateSingleItemTax() * quantity;

            //act
            double actualTax = item.CalculateTotalTax();

            //assert
            Assert.AreEqual(expectedTax, actualTax, "total tax incorrectly calculated for item with quantity of 4");
        }
Ejemplo n.º 4
0
        public void CalculateTotalCost_WithMultipleItems_CalculatesTotalCost()
        {
            //arrange
            double             price       = 12.5;
            int                quantity    = 3;
            ShoppingBasketItem item        = new ShoppingBasketItem(new Product("test", price), quantity);
            double             expectedTax = (item.CalculateSingleItemTax() + price) * quantity;

            //act
            double actualTax = item.CalculateTotalCost();

            //assert
            Assert.AreEqual(expectedTax, actualTax, "total cost incorrectly calculated for item with quantity of 3");
        }