예제 #1
0
        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 EmployeeValidator_OnValidade_MustFailValidation()
        {
            // Arrange
            var validator = new EmployeeValidator();

            // Act
            var results = validator.Validate(_employeeFixture.GenerateInvalidEmployee());

            // Assert
            Assert.False(results.IsValid);
            Assert.True(results.Errors.Any());
        }