コード例 #1
0
        public void AllGetTotalMethod_HaveAllPromotionDiscountCase_ShouldCalculateCorrectly()
        {
            IExpensesCalculator expensesCalculator = GetExpensesCalculatorThatHaveAllDiscountPromotion();
            double expectedTotalCost     = 1450;
            double expectedtotalDiscount = _snackCostForDiscountPromotionTest + (_furnitureCostForDiscountPromotionTest * 0.10) + (_medicineCostForDiscountPromotionTest * 0.15);
            double expectedtotalPay      = (expectedTotalCost - expectedtotalDiscount) + ((expectedTotalCost - expectedtotalDiscount) * TAX_RATE);
            double actualTotalCost       = expensesCalculator.GetTotalCost();
            double actualTotalDiscount   = expensesCalculator.GetTotalDiscount();
            double actualTotalPay        = expensesCalculator.GetTotalPay();

            Assert.AreEqual(expectedTotalCost, actualTotalCost);
            Assert.AreEqual(expectedtotalDiscount, actualTotalDiscount);
            Assert.AreEqual(expectedtotalPay, actualTotalPay);
        }
コード例 #2
0
        public void AllGetTotalMethod_HaveMedicineDiscountCase_ShouldCalculateCorrectly()
        {
            IExpensesCalculator expensesCalculator = GetExpensesCalculatorThatHaveDiscountFromMedicine();
            double expectedTotalCost     = 900;
            double expectedtotalDiscount = _medicineCostForDiscountPromotionTest * 0.15;
            double expectedtotalPay      = (expectedTotalCost - expectedtotalDiscount) + ((expectedTotalCost - expectedtotalDiscount) * TAX_RATE);
            double actualTotalCost       = expensesCalculator.GetTotalCost();
            double actualTotalDiscount   = expensesCalculator.GetTotalDiscount();
            double actualTotalPay        = expensesCalculator.GetTotalPay();

            Assert.AreEqual(expectedTotalCost, actualTotalCost);
            Assert.AreEqual(expectedtotalDiscount, actualTotalDiscount);
            Assert.AreEqual(expectedtotalPay, actualTotalPay);
        }
コード例 #3
0
        public void AllGetTotalMethod_HaveNoDiscountCase_ShouldCalculateCorrectly()
        {
            IExpensesCalculator expensesCalculator = GetExpensesCalculatorThatHaveNothingDiscount();
            double expectedTotalCost     = 900;
            double expectedtotalDiscount = 0;
            double expectedtotalPay      = (expectedTotalCost - expectedtotalDiscount) + ((expectedTotalCost - expectedtotalDiscount) * TAX_RATE);
            double actualTotalCost       = expensesCalculator.GetTotalCost();
            double actualTotalDiscount   = expensesCalculator.GetTotalDiscount();
            double actualTotalPay        = expensesCalculator.GetTotalPay();

            Assert.AreEqual(expectedTotalCost, actualTotalCost);
            Assert.AreEqual(expectedtotalDiscount, actualTotalDiscount);
            Assert.AreEqual(expectedtotalPay, actualTotalPay);
        }
コード例 #4
0
        public void AllGetTotalMethod_BagHaveNothingProduct_ShouldCalculateCorrectly()
        {
            IShoppingBag shoppingBag = GetShoppingBagHaveNothingProduct();
            IEnumerable <IDiscountor> discountors        = GetDiscountors(20, shoppingBag);
            IExpensesCalculator       expensesCalculator = GetExpensesCalculator(shoppingBag, discountors);
            double expectedTotalCost     = 0;
            double expectedtotalDiscount = 0;
            double expectedtotalPay      = (expectedTotalCost - expectedtotalDiscount) * TAX_RATE;
            double actualTotalCost       = expensesCalculator.GetTotalCost();
            double actualTotalDiscount   = expensesCalculator.GetTotalDiscount();
            double actualTotalPay        = expensesCalculator.GetTotalPay();

            Assert.AreEqual(expectedTotalCost, actualTotalCost);
            Assert.AreEqual(expectedtotalDiscount, actualTotalDiscount);
            Assert.AreEqual(expectedtotalPay, actualTotalPay);
        }
コード例 #5
0
 public ExpensesCalculatorTests()
 {
     _calculator = new ExpensesCalculator();
 }
コード例 #6
0
 public SplitBillsService(IFileReader reader, IFileWriter writer, IExpensesCalculator calculator)
 {
     _fileReader = reader;
     _fileWriter = writer;
     _calculator = calculator;
 }