public void TestThat_SaveNewPassword_RedirectsToStepThree_WhenTheModelIsInvalid() { var controller = new ResetPasswordController(Substitute.For <IUserProfileRepository>(), Substitute.For <IResetPasswordThingy>(), Substitute.For <IResetPasswordEmailSender>()); controller.ModelState.AddModelError("", "invalid"); var result = (ViewResult)controller.SaveNewPassword(new ResetPasswordStepThreeModel()); Assert.That(result.ViewName, Is.EqualTo("Step3")); }
public void TestThat_SaveNewPassword_RedirectsToCompletions_WhenThePasswordWasBeChanged() { var resetPasswordThingy = Substitute.For <IResetPasswordThingy>(); resetPasswordThingy.ResetPassword(Arg.Any <string>(), Arg.Any <string>()).Returns(true); var controller = new ResetPasswordController(Substitute.For <IUserProfileRepository>(), resetPasswordThingy, Substitute.For <IResetPasswordEmailSender>()); var result = (RedirectToRouteResult)controller.SaveNewPassword(new ResetPasswordStepThreeModel()); Assert.That(result.RouteValues["action"], Is.EqualTo("Complete")); }
public void TestThat_SaveNewPassword_RedirectsToStepThree_WhenThePasswordCouldNotBeChanged() { var resetPasswordThingy = Substitute.For <IResetPasswordThingy>(); resetPasswordThingy.ResetPassword(Arg.Any <string>(), Arg.Any <string>()).Returns(false); var controller = new ResetPasswordController(Substitute.For <IUserProfileRepository>(), resetPasswordThingy, Substitute.For <IResetPasswordEmailSender>()); var result = (ViewResult)controller.SaveNewPassword(new ResetPasswordStepThreeModel()); Assert.That(result.ViewName, Is.EqualTo("Step3")); }
public void TestThat_SaveNewPassword_AddsAnError_WhenThePasswordCouldNotBeChanged() { var resetPasswordThingy = Substitute.For <IResetPasswordThingy>(); resetPasswordThingy.ResetPassword(Arg.Any <string>(), Arg.Any <string>()).Returns(false); var controller = new ResetPasswordController(Substitute.For <IUserProfileRepository>(), resetPasswordThingy, Substitute.For <IResetPasswordEmailSender>()); controller.SaveNewPassword(new ResetPasswordStepThreeModel()); Assert.That(controller.ModelState.Count, Is.EqualTo(1)); }