コード例 #1
0
        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);
        }
コード例 #2
0
        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);
        }
コード例 #3
0
        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);
        }
コード例 #4
0
        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
            });
        }