public IEnumerable <ValidationResult> Validate(ValidationContext validationContext)
        {
            var validator = new UserAccountConfirmationModelValidator();
            var result    = validator.Validate(this);

            return(result.Errors.Select(item => new ValidationResult(item.ErrorMessage, new[] { item.PropertyName })));
        }
예제 #2
0
        public void UserAccountConfirmationModelValidResult()
        {
            var validator = new UserAccountConfirmationModelValidator();

            validator.ShouldHaveValidationErrorFor(model => model.Code, "");
            validator.ShouldHaveValidationErrorFor(model => model.Code, "12345");
            validator.ShouldHaveValidationErrorFor(model => model.Code, "125");
            validator.ShouldNotHaveValidationErrorFor(model => model.Code, "1234");
        }