Пример #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);
 }
Пример #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);
 }
Пример #3
0
 void EmployeesWithNamesThatStartWithAShouldGetADiscount()
 {
     var employee = new Employee("Apollo", "Astronaut");
     var cost = calculator.CostOfBenefits(employee);
     Assert.Equal(900, cost);
 }
Пример #4
0
 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;
 }