public void CalculateTaxes_income_tax_correct_values(decimal minApplyAmount, decimal percent, decimal salary, decimal expected) { var rule = new IncomeTaxRule(percent, minApplyAmount); var calc = new Calculator(new List <ITaxRule> { rule }); var res = calc.ApplyTaxes(salary); Assert.Equal(res, expected); }
public void CalculateTaxes_invalid_salary_must_return_0() { var rule1 = new IncomeTaxRule(10, 0); var rule2 = new SocialContributionsRule(15, 0, 0); var calc = new Calculator(new List <ITaxRule> { rule1, rule2 }); var res = calc.ApplyTaxes(0); Assert.Equal(0, res); }
public void CalculateTaxes_all_rules_correct_values(decimal minApplyAmount, decimal maxApplyAmount, decimal percent1, decimal percent2, decimal salary, decimal expected) { var rule1 = new IncomeTaxRule(percent1, minApplyAmount); var rule2 = new SocialContributionsRule(percent2, minApplyAmount, maxApplyAmount); var calc = new Calculator(new List <ITaxRule> { rule1, rule2 }); var res = calc.ApplyTaxes(salary); Assert.Equal(expected, res); }
private static Calculator GetCalculator(AppSettings settings) { var incomeTax = new IncomeTaxRule( settings.IncomeTax.Percent, settings.IncomeTax.MinApplyAmount ); var socialContributions = new SocialContributionsRule( settings.SocialContributions.Percent, settings.SocialContributions.MinApplyAmount, settings.SocialContributions.MaxApplyAmount ); return(new Calculator(new List <ITaxRule> { incomeTax, socialContributions })); }