public void ResetPasswordRequestIsMade_InvalidPassword_ValidationShouldFail(string inputPassword) { var validatorService = new PasswordValidator(CreateDefaultValidationRules()); var request = new ResetPasswordRequestModel() { Password = inputPassword }; var validator = new ResetPasswordRequestValidator(validatorService); var result = validator.Validate(request); Assert.False(result.IsValid); }
public void ResetPasswordRequestIsMade_InvalidEmail_ValidationShouldFail() { var validatorService = new PasswordValidator(CreateDefaultValidationRules()); var request = new ResetPasswordRequestModel() { CustomerEmail = "invalid.email", Password = "******" }; var validator = new ResetPasswordRequestValidator(validatorService); var result = validator.Validate(request); Assert.False(result.IsValid); }
public void ResetPasswordRequestIsMade_EverythingValid_ValidationShouldSucceed() { var validatorService = new PasswordValidator(CreateDefaultValidationRules()); var request = new ResetPasswordRequestModel() { CustomerEmail = "*****@*****.**", Password = "******", ResetIdentifier = "resetIdentifier" }; var validator = new ResetPasswordRequestValidator(validatorService); var result = validator.Validate(request); Assert.True(result.IsValid); }
public ValidationResult ValidateResetPasswordRequest(ResetPasswordRequest request) { var validator = new ResetPasswordRequestValidator(_queries); var result = validator.Validate(request); var errors = new Dictionary <string, string>(); if (result.Errors.Any()) { errors.Add("Id", result.Errors.First().Value); } return(new ValidationResult { Errors = errors }); }