public void Validate_GivenAllPropertiesAreValid_ExpectValidationSuccess() { var cmd = new PasswordResetCommand("token", "new-password"); var validator = new PasswordResetCommandValidator(); var result = validator.Validate(cmd); Assert.True(result.IsValid); }
public void Validate_GivenTokenIsNull_ExpectValidationFailure() { var cmd = new PasswordResetCommand(null, "new-password"); var validator = new PasswordResetCommandValidator(); var result = validator.Validate(cmd); Assert.False(result.IsValid); Assert.Contains( result.Errors, failure => failure.ErrorCode.Equals(ValidationCodes.FieldIsRequired) && failure.PropertyName == "Token"); }
public void Validate_GivenNewPasswordIsEmpty_ExpectValidationFailure() { var cmd = new PasswordResetCommand("token", string.Empty); var validator = new PasswordResetCommandValidator(); var result = validator.Validate(cmd); Assert.False(result.IsValid); Assert.Contains( result.Errors, failure => failure.ErrorCode.Equals(ValidationCodes.FieldIsRequired) && failure.PropertyName == "NewPassword"); }