示例#1
0
        public void ApplyTaxRule_RoundingTaxRule_RoundsToNearestWholeNumber()
        {
            //arrange
            ITaxRule rule        = new RoundingTaxRule();
            double   tax         = 1.98;
            double   expectedTax = 2.00;

            //act
            double actualTax = rule.ApplyTaxRule(tax);

            //assert
            Assert.AreEqual(expectedTax, actualTax, "Rounding rule did not correctly round tax");
        }
示例#2
0
        public void ApplyTaxRule_RoundingTaxRule_RoundsTaxValue()
        {
            //arrange
            ITaxRule rule        = new RoundingTaxRule();
            double   tax         = 1.41;
            double   expectedTax = 1.45;

            //act
            double actualTax = rule.ApplyTaxRule(tax);

            //assert
            Assert.AreEqual(expectedTax, actualTax, "Rounding rule did not correctly round tax");
        }
示例#3
0
        public void CalculateSingleTax_WithExemptTaxAndRoundingRule_CalculatesTaxValue()
        {
            //arrange
            double             price       = 1.5;
            ShoppingBasketItem item        = new ShoppingBasketItem(new Product("test", price, ProductType.Medical));
            double             expectedTax = new RoundingTaxRule().ApplyTaxRule(new ExemptSalesTaxRate().CalculateTax(price));

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

            //assert
            Assert.AreEqual(expectedTax, actualTax, "Single item tax incorrectly calculated for item with exempt tax rate");
        }