示例#1
0
        public void EmployeeSalaryCannotBeMoreThanWageBudget(BonusPoolTestData testData)
        {
            var calculator = new BonusPoolCalculator(testData.WageBudget, testData.BonusPoolValue);

            Action calculate = () => calculator.CalculateBonusAllocation(testData.EmployeeSalary);

            Assert.ThrowsException <ArgumentOutOfRangeException>(calculate, "Employee salary cannot be greater than the wage budget");
        }
示例#2
0
        public void BonusIsGivenToTwoDecimalPlaces(BonusPoolTestData testData)
        {
            var calculator = new BonusPoolCalculator(testData.WageBudget, testData.BonusPoolValue);

            decimal bonus        = calculator.CalculateBonusAllocation(testData.EmployeeSalary);
            decimal bonusRounded = Decimal.Round(bonus, 2);

            Assert.AreEqual(bonusRounded, bonus);
        }
示例#3
0
        public void BonusPercentageOfPoolEqualsSalaryPercentageOfWageBudget(BonusPoolTestData testData)
        {
            var     calculator     = new BonusPoolCalculator(testData.WageBudget, testData.BonusPoolValue);
            decimal basePercentage = testData.WageBudget != 0 ? testData.EmployeeSalary / testData.WageBudget : 0;
            decimal expectedBonus  = Math.Floor(basePercentage * testData.BonusPoolValue * 100) / 100;

            decimal bonus = calculator.CalculateBonusAllocation(testData.EmployeeSalary);

            Assert.AreEqual(expectedBonus, bonus);
        }
示例#4
0
        public ActionResult Calculate(BonusPoolCalculatorModel model)
        {
            int selectedEmployeeId = model.SelectedEmployeeId;
            int totalBonusPool     = model.BonusPoolAmount;

            //load the details of the selected employee using the ID
            HrEmployee hrEmployee = _hrEmployeeRepository.Get(selectedEmployeeId);

            int employeeSalary = hrEmployee.Salary;

            //get the total salary budget for the company
            int totalSalary = _hrEmployeeRepository.GetSumOfSalaries();

            //calculate the bonus allocation for the employee
            BonusPoolCalculator calculator      = new BonusPoolCalculator(totalSalary, totalBonusPool);
            decimal             bonusAllocation = calculator.CalculateBonusAllocation(employeeSalary);

            BonusPoolCalculatorResultModel result = new BonusPoolCalculatorResultModel();

            result.hrEmployee          = hrEmployee;
            result.bonusPoolAllocation = bonusAllocation;

            return(View(result));
        }