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);
 }
 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);
 }
 void EmployeesWithNamesThatStartWithAShouldGetADiscount()
 {
     var employee = new Employee("Apollo", "Astronaut");
     var cost = calculator.CostOfBenefits(employee);
     Assert.Equal(900, cost);
 }
 void EmployeeCostShouldNormallyBe1000()
 {
     var employee = new Employee("Caleb", "Jares");
     var cost = calculator.CostOfBenefits(employee);
     Assert.Equal(1000, cost);
 }
示例#5
0
 public decimal GrossPayPerPeriod(Employee employee)
 {
     var deductionPerPayPeriod = benefitsCalculator.CostOfBenefits(employee) / PayPeriodsPerYear;
     return BasePay - deductionPerPayPeriod;
 }
示例#6
0
 private decimal TotalDependentsDiscount(Employee employee)
 {
     return employee.Dependents.Sum(dependent => CostForDependent * PercentageDiscountForPerson(dependent));
 }
示例#7
0
 public decimal CostOfBenefits(Employee employee)
 {
     var employeeCost = CostForEmployee * (1 - PercentageDiscountForPerson(employee));
     var dependentCost = CostForDependent * employee.Dependents.Count() - TotalDependentsDiscount(employee);
     return employeeCost + dependentCost;
 }