Exemplo n.º 1
0
 void EmployeesWithDependentsShouldBeChargedMore()
 {
     var dependents = new[] {new Person("Bill", "Gates"), new Person("Roger", "Waters") };
     var employee = new Employee("Jack", "theRipper", dependents);
     var cost = calculator.CostOfBenefits(employee);
     Assert.Equal(1000 + 500 * 2, cost);
 }
Exemplo n.º 2
0
 void EmployeeWithAnANameDependentShouldGetADiscount()
 {
     var dependents = new[] { new Person("A", "Discount"), new Person("Not", "Discounted"), new Person("Boom", "Boom"),  };
     var employee = new Employee("Some", "Person", dependents);
     var cost = calculator.CostOfBenefits(employee);
     Assert.Equal((decimal) (1000 + 500 + 500 + 500 * .9), cost);
 }
Exemplo n.º 3
0
 void EmployeesWithNamesThatStartWithAShouldGetADiscount()
 {
     var employee = new Employee("Apollo", "Astronaut");
     var cost = calculator.CostOfBenefits(employee);
     Assert.Equal(900, cost);
 }
Exemplo n.º 4
0
 void EmployeeCostShouldNormallyBe1000()
 {
     var employee = new Employee("Caleb", "Jares");
     var cost = calculator.CostOfBenefits(employee);
     Assert.Equal(1000, cost);
 }
Exemplo n.º 5
0
 public decimal GrossPayPerPeriod(Employee employee)
 {
     var deductionPerPayPeriod = benefitsCalculator.CostOfBenefits(employee) / PayPeriodsPerYear;
     return BasePay - deductionPerPayPeriod;
 }
Exemplo n.º 6
0
 private decimal TotalDependentsDiscount(Employee employee)
 {
     return employee.Dependents.Sum(dependent => CostForDependent * PercentageDiscountForPerson(dependent));
 }
Exemplo n.º 7
0
 public decimal CostOfBenefits(Employee employee)
 {
     var employeeCost = CostForEmployee * (1 - PercentageDiscountForPerson(employee));
     var dependentCost = CostForDependent * employee.Dependents.Count() - TotalDependentsDiscount(employee);
     return employeeCost + dependentCost;
 }