public void ResetsPasswordForValidToken() { var controller = new TestableUsersController(); controller.MockUserService .Setup(u => u.ResetPasswordWithToken("user", "token", "newpwd")) .Returns(true); var model = new PasswordResetViewModel { ConfirmPassword = "******", NewPassword = "******" }; var result = controller.ResetPassword("user", "token", model) as RedirectToRouteResult; Assert.NotNull(result); controller.MockUserService .Verify(u => u.ResetPasswordWithToken("user", "token", "newpwd")); }
public void ShowsErrorIfTokenExpired() { var controller = new TestableUsersController(); controller.MockUserService .Setup(u => u.ResetPasswordWithToken("user", "token", "newpwd")) .Returns(false); var model = new PasswordResetViewModel { ConfirmPassword = "******", NewPassword = "******" }; controller.ResetPassword("user", "token", model); Assert.Equal("The Password Reset Token is not valid or expired.", controller.ModelState[""].Errors[0].ErrorMessage); controller.MockUserService .Verify(u => u.ResetPasswordWithToken("user", "token", "newpwd")); }