示例#1
0
        public IEnumerable <ValidationResult> Validate(ValidationContext validationContext)
        {
            var validator = new NewPasswordModelValidator();
            var result    = validator.Validate(this);

            return(result.Errors.Select(item => new ValidationResult(item.ErrorMessage, new[] { item.PropertyName })));
        }
示例#2
0
        public void GivenValidate_WithNewPasswordNull_ThenResultShouldBeInvalid()
        {
            var newPaswordModel = NewPasswordModelFactory.Default().WithNewPassword(null);
            var validator       = new NewPasswordModelValidator();

            var result = validator.Validate(newPaswordModel);

            result.IsValid.Should().BeFalse();
            result.Errors.Count.Should().Be(1);
        }
示例#3
0
        public void GivenValidate_WithNewPasswordLengthEqualWith8_ThenResultShouldBeValid()
        {
            var newPaswordModel = NewPasswordModelFactory.Default().WithNewPassword("12345678");
            var validator       = new NewPasswordModelValidator();

            var result = validator.Validate(newPaswordModel);

            result.IsValid.Should().BeTrue();
            result.Errors.Count.Should().Be(0);
        }
示例#4
0
        public void GivenValidate_WithValidInput_ThenResultShouldBeValid()
        {
            var newPaswordModel = NewPasswordModelFactory.Default();
            var validator       = new NewPasswordModelValidator();

            var result = validator.Validate(newPaswordModel);

            result.IsValid.Should().BeTrue();
            result.Errors.Count.Should().Be(0);
        }