public void ShouldValidateOnChangePasswordModelIsAllRule() { var model = new ChangePasswordModel { NewPassword = "******" }; //we know that new password should equal confirmation password model.ConfirmNewPassword = model.NewPassword; _changePasswordValidator.TestValidate(model).ShouldHaveValidationErrorFor(x => x.NewPassword); model.NewPassword = "******"; //we know that new password should equal confirmation password model.ConfirmNewPassword = model.NewPassword; _changePasswordValidator.TestValidate(model).ShouldNotHaveValidationErrorFor(x => x.NewPassword); }
public void ShouldHaveErrorWhenOldPasswordIsNullOrEmpty() { var model = new ChangePasswordModel { OldPassword = null }; _validator.TestValidate(model).ShouldHaveValidationErrorFor(x => x.OldPassword); model.OldPassword = string.Empty; _validator.TestValidate(model).ShouldHaveValidationErrorFor(x => x.OldPassword); }