Example #1
0
        private static List <MonthlyPayslipResult> GetCalculationResults(IEnumerable <Employee> employees)
        {
            var incomeTaxTable = GetIncomeTaxTable();
            var calculator     = new MonthlyPayslipCalculator(incomeTaxTable);

            var calculationResults = new List <MonthlyPayslipResult>();

            foreach (var employee in employees)
            {
                calculationResults.Add(calculator.Calculate(employee));
            }

            return(calculationResults);
        }
        public void Can_Calculate_Monthly_Payslip_For_Ryan_Chen()
        {
            var incomeTaxTable = GetTaxTable();
            var calculator     = new MonthlyPayslipCalculator(incomeTaxTable);

            var employee = new Employee
            {
                FirstName = "Ryan",
                LastName  = "Chen",
                PayPeriod = "01 March – 31 March",
                Salary    = 120000,
                SuperRate = 10
            };


            var result = calculator.Calculate(employee);

            Assert.AreEqual("Ryan Chen", result.EmployeeFullName);
            Assert.AreEqual("01 March – 31 March", result.EmployeePayPeriod);
            Assert.AreEqual(10000, result.GrossIncome);
            Assert.AreEqual(2696, result.IncomeTax);
            Assert.AreEqual(7304, result.NetIncome);
            Assert.AreEqual(1000, result.Super);
        }
        public void Can_Calculate_Monthly_Payslip_For_David_Rudd()
        {
            var incomeTaxTable = GetTaxTable();
            var calculator     = new MonthlyPayslipCalculator(incomeTaxTable);

            var employee = new Employee
            {
                FirstName = "David",
                LastName  = "Rudd",
                PayPeriod = "01 March – 31 March",
                Salary    = 60050,
                SuperRate = 9
            };


            var result = calculator.Calculate(employee);

            Assert.AreEqual("David Rudd", result.EmployeeFullName);
            Assert.AreEqual("01 March – 31 March", result.EmployeePayPeriod);
            Assert.AreEqual(5004, result.GrossIncome);
            Assert.AreEqual(922, result.IncomeTax);
            Assert.AreEqual(4082, result.NetIncome);
            Assert.AreEqual(450, result.Super);
        }