Exemplo n.º 1
0
        public void Test_CalculateDeductions()
        {
            decimal           grossAmount = (decimal)1000;
            IList <ItemRates> itemRates   = new[]
            {
                new ItemRates("Income Tax", new []
                {
                    new Rate((decimal)0.00, (decimal)600.00, (decimal)25),
                    new Rate((decimal)601.00, decimal.MaxValue, (decimal)40)
                }),
                new ItemRates("Universal Social Charge", new[]
                {
                    new Rate((decimal)0.00, (decimal)500.00, (decimal)7),
                    new Rate((decimal)501.00, decimal.MaxValue, (decimal)8)
                })
            };
            IDeductionChargeCalculator chargeCalculator = new DeductionChargeCalculator();
            IList <ItemDeduction>      itemDeductions   = chargeCalculator.CalculateDeductions(grossAmount, itemRates);

            Assert.AreEqual(2, itemDeductions.Count);
            Assert.AreEqual("Income Tax", itemDeductions[0].DeductionItemName);
            Assert.AreEqual((decimal)310, itemDeductions[0].DeductionCharge);
            Assert.AreEqual("Universal Social Charge", itemDeductions[1].DeductionItemName);
            Assert.AreEqual((decimal)75, itemDeductions[1].DeductionCharge);
        }
Exemplo n.º 2
0
        public void Test_CalculateDeduction()
        {
            decimal   grossAmount = (decimal)1000;
            ItemRates itemRates   = new ItemRates("Income Tax", new[]
            {
                new Rate((decimal)0.00, (decimal)600.00, (decimal)25),
                new Rate((decimal)601.00, decimal.MaxValue, (decimal)40)
            });
            IDeductionChargeCalculator chargeCalculator = new DeductionChargeCalculator();
            PrivateObject obj          = new PrivateObject(chargeCalculator);
            ItemDeduction itemDedution = (ItemDeduction)obj.Invoke("CalculateDeduction", grossAmount, itemRates);

            Assert.AreEqual("Income Tax", itemDedution.DeductionItemName);
            Assert.AreEqual((decimal)310, itemDedution.DeductionCharge);
        }
        public void Test_GetDeductionChargeDetailInfo()
        {
            EmployeePayroll _employeePayroll                       = new EmployeePayroll(40, 25, "Ireland");
            ILocationItemRatesProvider_Get _rateProvider           = new LocationItemRatesProvider();
            IDeductionChargeCalculator     _chargeCalculator       = new DeductionChargeCalculator();
            EmployeePayrollManager         _employeePayrollManager = new EmployeePayrollManager(_employeePayroll, _rateProvider, _chargeCalculator);
            string payrollDetailInfo = _employeePayrollManager.GetDeductionChargeDetailInfo();

            StringBuilder sb = new StringBuilder();

            sb.AppendLine(string.Format("Employee location: {0}\r\n", "Ireland"));
            sb.AppendLine(string.Format("Gross Amount:{0:C}\r\n", (decimal)1000.00));
            sb.AppendLine("Less deductions:\r\n");

            sb.AppendLine(string.Format("{0}:{1:C}", "Income Tax", (decimal)310.00));
            sb.AppendLine(string.Format("{0}:{1:C}", "Universal Social Charge", (decimal)75.00));
            sb.AppendLine(string.Format("{0}:{1:C}", "Pension", (decimal)40.00));

            sb.AppendLine(string.Format("Net Amount:{0:C}", (decimal)575.00));
            Assert.AreEqual(sb.ToString(), payrollDetailInfo);
        }