コード例 #1
0
        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());
        }
コード例 #2
0
        private Paycheck ComputePaycheck(
            Employee employee,
            DateTime referenceMonth)
        {
            if (PaycheckServiceExtensions.IsEmployeeValid(this, employee))
            {
                var entries = ComputeEntries(employee, referenceMonth);

                var paycheck = new Paycheck(entries, referenceMonth, employee.GrossSalary);
                paycheck.EmployeeName = employee.GetFullName();

                var validator        = new PaycheckValidator();
                var validationResult = validator.Validate(paycheck);
                if (validationResult.IsValid)
                {
                    return(paycheck);
                }

                return(null);
            }

            return(null);
        }