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 }))); }
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); }
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); }
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); }