コード例 #1
0
        public void TestWithPositiveSalary()
        {
            var  errorMessage = string.Empty;
            bool result       = SalaryValidator.Validate(2000, out errorMessage);

            Assert.IsTrue(result);
            Assert.IsEmpty(errorMessage);
        }
コード例 #2
0
        public void TestWithNegativeSalary()
        {
            var  errorMessage = string.Empty;
            bool result       = SalaryValidator.Validate(-1000, out errorMessage);

            Assert.IsFalse(result);
            Assert.IsNotNull(errorMessage);
            Assert.IsNotEmpty(errorMessage);
        }
コード例 #3
0
        protected override IEnumerable <ValidationError> Validation()
        {
            var result = Enumerable.Empty <ValidationError>();

            var validationErrors = SalaryValidator.Validate(this);

            if (!validationErrors.IsNullOrEmpty())
            {
                result = result.Concat(validationErrors);
            }

            if (!secondPhaseErrors.IsNullOrEmpty())
            {
                result = result.Concat(secondPhaseErrors);
            }

            return(result);
        }