public void Should_validate_newPassword_is_length() { _customerSettings.PasswordMinLength = 5; _validator = new PasswordRecoveryConfirmValidator(_localizationService, _customerSettings); var model = new PasswordRecoveryConfirmModel(); model.NewPassword = "******"; //we know that new password should equal confirmation password model.ConfirmNewPassword = model.NewPassword; _validator.ShouldHaveValidationErrorFor(x => x.NewPassword, model); model.NewPassword = "******"; //we know that new password should equal confirmation password model.ConfirmNewPassword = model.NewPassword; _validator.ShouldNotHaveValidationErrorFor(x => x.NewPassword, model); }
public void Should_validate_on_PasswordRecoveryConfirmModel_is_all_rule() { _passwordRecoveryConfirmValidator = new PasswordRecoveryConfirmValidator(_localizationService, _customerSettings); var model = new PasswordRecoveryConfirmModel { NewPassword = "******" }; //we know that new password should equal confirmation password model.ConfirmNewPassword = model.NewPassword; _passwordRecoveryConfirmValidator.ShouldHaveValidationErrorFor(x => x.NewPassword, model); model.NewPassword = "******"; //we know that new password should equal confirmation password model.ConfirmNewPassword = model.NewPassword; _passwordRecoveryConfirmValidator.ShouldNotHaveValidationErrorFor(x => x.NewPassword, model); }
public new void Setup() { _customerSettings = new CustomerSettings { PasswordMinLength = 8, PasswordRequireUppercase = true, PasswordRequireLowercase = true, PasswordRequireDigit = true, PasswordRequireNonAlphanumeric = true }; _changePasswordValidator = new ChangePasswordValidator(_localizationService, _customerSettings); _stateProvinceService = new Mock <IStateProvinceService>(); _registerValidator = new RegisterValidator(_localizationService, _stateProvinceService.Object, _customerSettings); _passwordRecoveryConfirmValidator = new PasswordRecoveryConfirmValidator(_localizationService, _customerSettings); _validator = new TestValidator(); _person = new Person(); }
public ActionResult PasswordRecoveryConfirmPOST(string token, string username, PasswordRecoveryConfirmModel model) { FluentValidation.IValidator <PasswordRecoveryConfirmModel> validator = new PasswordRecoveryConfirmValidator(); var validationResults = validator.Validate(model); foreach (var item in validationResults.Errors) { ModelState.AddModelError(item.PropertyName, item.ErrorMessage); } if (ModelState.IsValid) { try { var result = _webClient.UploadData <UserStatusEnum>("passwordrecoverysubmit", new { NewPassword = model.NewPassword, Token = token }); switch (result) { case UserStatusEnum.Success: model.Result = Resource.PasswordRecoveryConfirm_successmsg; model.SuccessfullyChanged = true; return(RedirectToAction("PasswordRecoveryConfirmResult")); case UserStatusEnum.UserAccountNotExist: model.Result = Resource.PasswordRecoveryConfirm_noaccount; break; case UserStatusEnum.InvalidToken: model.Result = Resource.PasswordRecoveryConfirm_invalidtoken.Replace("%SITEURL%", Url.RouteUrl("PasswordRecovery")); break; default: return(RedirectToRoute("HomePage")); } } catch (Exception ex) { ModelState.AddModelError("", ex.Message); } } //redisplay page if any error return(View(model)); }
public new void Setup() { _customerSettings = new CustomerSettings(); _validator = new PasswordRecoveryConfirmValidator(_localizationService, _customerSettings); }
public void Setup() { _validator = GetService <PasswordRecoveryConfirmValidator>(); }
public new void Setup() { _customerSettings = new CustomerSettings(); _validator = new PasswordRecoveryConfirmValidator(T, _customerSettings); }