예제 #1
0
        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"));
        }
예제 #2
0
        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"));
        }
예제 #3
0
        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"));
        }
예제 #4
0
        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));
        }