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