public int ProcessCustomer(Customer customer) { if (customer.Type == CustomerType.Personal) { ITaxCalculator personalTaxCalculator = new PersonalTaxCalculator(); return(personalTaxCalculator.CalculateTax(customer.Money)); } ITaxCalculator linearTaxCalculator = new LinearTaxCalculator(); return(linearTaxCalculator.CalculateTax(customer.Money)); }
public void T001_CalculateLinearTaxForCompany() { // Given int receivedMoney = 20000; // Expected int expectedTax = (int)(receivedMoney * 0.19); // When int linearTax = new LinearTaxCalculator().CalculateTax(receivedMoney); // Then Assert.AreEqual(expectedTax, linearTax); }
public int ProcessCustomers(List <Customer> customers) { ITaxCalculator personalTaxCalculator = new PersonalTaxCalculator(); ITaxCalculator linearTaxCalculator = new LinearTaxCalculator(); int linear = 0; int personal = 0; foreach (var customer in customers) { if (customer.Type == CustomerType.Personal) { personal += personalTaxCalculator.CalculateTax(customer.Money); } else { linear += linearTaxCalculator.CalculateTax(customer.Money); } } return(linear + personal); }