// DI ideally uses interfaces for the minimum sake of super easy unit test mocking // Pretend these are interfaces *waves magic hands* public EmployeeApiController(EmployeeCrud employeeCrud, EmployeeCostCalculator costCalculator, EmployeeValidator employeeValidator) { _employeeCrud = employeeCrud; _costCalculator = costCalculator; _employeeValidator = employeeValidator; }
public void CalculateTests(Employee employee, EmployeeCostPerPaycheckDto expected) { // Act var result = new EmployeeCostCalculator().Calculate(employee); // Assert Assert.AreEqual(Math.Round(expected.Pay, 5), Math.Round(result.Pay)); Assert.AreEqual(Math.Round(expected.BenefitsDiscount, 5), Math.Round(result.BenefitsDiscount, 5)); Assert.AreEqual(Math.Round(expected.BenefitsDeduction, 5), Math.Round(result.BenefitsDeduction, 5)); Assert.AreEqual(Math.Round(expected.DependentBenefitsDeduction, 5), Math.Round(result.DependentBenefitsDeduction, 5)); Assert.AreEqual(Math.Round(expected.NetCost, 5), Math.Round(result.NetCost, 5)); }