public void PaycheckService_OnWork_CalculateIrpfCorrectly() { // Arrange var referenceMonth = DateTime.Now; var service = new PaycheckService(new EmployeeValidator()); var paycheck = service.CreatePaycheck(_employeeFixture.GenerateValidEmployee(), referenceMonth).Result; var irrf = paycheck.Payload.Entries.Find(x => x.Description == "IRRF"); var noIrrf = service .CreatePaycheck(_employeeFixture.GenerateValidEmployeeNoIrrfDiscount(), referenceMonth) .Result.Payload.Entries.Find(x => x.Description == "IRRF"); // Assert Assert.Equal((5000 * (27.5m / 100)) - 869.36m, irrf.Value); Assert.Equal(0, noIrrf.Value); }
public void PaycheckService_OnWork_CalculateTransportTicketCorrectly() { // Arrange var referenceMonth = DateTime.Now; var service = new PaycheckService(new EmployeeValidator()); var paycheck = service.CreatePaycheck(_employeeFixture.GenerateValidEmployee(), referenceMonth).Result; var tt = paycheck.Payload.Entries.Find(x => x.Description == "Vale Transporte"); var noTt = service .CreatePaycheck(_employeeFixture.GenerateValidEmployeeNoOptionalDiscounts(), referenceMonth) .Result.Payload.Entries.Find(x => x.Description == "Vale Transporte"); // Assert Assert.Equal(5000 * (6m / 100), tt.Value); Assert.Equal(0, noTt.Value); }
public void PaycheckService_OnWork_CalculateDentalPlanCorrectly() { // Arrange var referenceMonth = DateTime.Now; var service = new PaycheckService(new EmployeeValidator()); var paycheck = service.CreatePaycheck(_employeeFixture.GenerateValidEmployee(), referenceMonth).Result; var dp = paycheck.Payload.Entries.Find(x => x.Description == "Plano Dentário"); var noDp = service .CreatePaycheck(_employeeFixture.GenerateValidEmployeeNoOptionalDiscounts(), referenceMonth) .Result.Payload.Entries.Find(x => x.Description == "Plano Dentário"); // Assert Assert.Equal(5, dp.Value); Assert.Equal(0, noDp.Value); }
public void PaycheckService_OnWork_GenerateAValidAndAInvalidPaycheck() { // Arrange var referenceMonth = DateTime.Now; var service = new PaycheckService(new EmployeeValidator()); // Act var validPaycheck = service.CreatePaycheck(_employeeFixture.GenerateValidEmployee(), referenceMonth).Result; var invalidPaycheck = service.CreatePaycheck(_employeeFixture.GenerateInvalidEmployee(), referenceMonth) .Result; // Assert Assert.True(validPaycheck.Payload != null); Assert.False(validPaycheck.ErrorMessages.Any()); Assert.False(invalidPaycheck.Payload != null); Assert.True(invalidPaycheck.ErrorMessages.Any()); }
public void PaycheckService_OnWork_ThrowExceptionWhenTryValidade() { // Arrange var referenceMonth = DateTime.Now; var service = new PaycheckService(new EmployeeValidator()); // Assert Assert.ThrowsAsync <Exception>(() => service.CreatePaycheck(_employeeFixture.GenerateInvalidEmployee(), referenceMonth)); }
public void PaycheckService_OnWork_CalculateFgtsCorrectly() { // Arrange var referenceMonth = DateTime.Now; var service = new PaycheckService(new EmployeeValidator()); var paycheck = service.CreatePaycheck(_employeeFixture.GenerateValidEmployee(), referenceMonth).Result; var fgts = paycheck.Payload.Entries.Find(x => x.Description == "FGTS"); // Assert Assert.Equal(5000 * (8m / 100), fgts.Value); }
public void PaycheckValidator_OnValidade_MustPassValidation() { // Arrange var referenceMonth = DateTime.Today; var validator = new PaycheckValidator(); var paycheckService = new PaycheckService(new EmployeeValidator()); var paycheck = paycheckService.CreatePaycheck(_employeeFixture.GenerateValidEmployee(), referenceMonth).Result; // Act var result = validator.Validate(paycheck.Payload); // Assert Assert.True(result.IsValid); Assert.False(result.Errors.Any()); }