예제 #1
0
        private void AddUser(object parameter)
        {
            UserValidation     userValidation     = new UserValidation(_userRepository);
            PasswordValidation passwordValidation = new PasswordValidation();

            try
            {
                userValidation.ValidateUserNameRegistration(UserName);
            }
            catch (ValidationException ex)
            {
                ErrorMessage = ex.Message;
                return;
            }

            try
            {
                passwordValidation.ValidatePasswordRegistration(Password, RepeatPassword);
            }
            catch (ValidationException ex)
            {
                ErrorMessage = ex.Message;
                return;
            }

            _userRepository.AddUser(new User()
            {
                Name = UserName, Password = passwordValidation.HashPassword(Password)
            });
            CurrentUser.Login(_userRepository.GetUserByName(UserName));
            CloseAction();
        }
        public void ValidatePasswordRegistration_InvalidPasswordLength_ExpectedException()
        {
            string             password       = "******";
            string             repeatPassword = "******";
            PasswordValidation passValidation = new PasswordValidation();

            passValidation.ValidatePasswordRegistration(password, repeatPassword);
        }
        public void ValidatePasswordRegistration_PasswordIsNull_ExpectedException()
        {
            string             password       = null;
            string             repeatPassword = null;
            PasswordValidation passValidation = new PasswordValidation();

            passValidation.ValidatePasswordRegistration(password, repeatPassword);
        }
        public void ValidatePasswordRegistration_PasswordsNotEqual_ExpectedException(string pass, string repeatPass)
        {
            PasswordValidation passValidation = new PasswordValidation();

            passValidation.ValidatePasswordRegistration(pass, repeatPass);
        }