Post() private method

private Post ( ForgotPasswordForm model ) : System.Web.Mvc.ActionResult
model ForgotPasswordForm
return System.Web.Mvc.ActionResult
Ejemplo n.º 1
0
            public void ReturnsRedirect_ToConfirmEmail_WithCommandToken()
            {
                var form = new ForgotPasswordForm
                {
                    EmailAddress = "*****@*****.**",
                };
                var commandHandler = new Mock<IHandleCommands<SendConfirmEmailMessageCommand>>
                    (MockBehavior.Strict);
                commandHandler.Setup(m => m.Handle(It.Is(SendCommandBasedOn(form))));
                var services = new ForgotPasswordServices(commandHandler.Object);
                var controller = new ForgotPasswordController(services);
                ReuseMock.TestControllerBuilder(ControllerCustomization.ForUrlHelper)
                    .InitializeController(controller);

                var result = controller.Post(form);

                result.ShouldNotBeNull();
                result.ShouldBeType<RedirectToRouteResult>();
                var routeResult = (RedirectToRouteResult)result;
                routeResult.Permanent.ShouldBeFalse();
                routeResult.RouteValues["area"].ShouldEqual(MVC.Identity.Name);
                routeResult.RouteValues["controller"].ShouldEqual(MVC.Identity.ConfirmEmail.Name);
                routeResult.RouteValues["action"].ShouldEqual(MVC.Identity.ConfirmEmail.ActionNames.Get);
                routeResult.RouteValues["token"].ShouldEqual(Guid.Empty);
            }
Ejemplo n.º 2
0
            public void Returns404_WhenModel_IsNull()
            {
                var controller = new ForgotPasswordController(null);

                var result = controller.Post(null);

                result.ShouldNotBeNull();
                result.ShouldBeType<HttpNotFoundResult>();
            }
Ejemplo n.º 3
0
            public void ExecutesCommand_WhenAction_IsValid()
            {
                var form = new ForgotPasswordForm
                {
                    EmailAddress = "*****@*****.**",
                };
                var commandHandler = new Mock<IHandleCommands<SendConfirmEmailMessageCommand>>
                    (MockBehavior.Strict);
                commandHandler.Setup(m => m.Handle(It.Is(SendCommandBasedOn(form))));
                var services = new ForgotPasswordServices(commandHandler.Object);
                var controller = new ForgotPasswordController(services);
                ReuseMock.TestControllerBuilder(ControllerCustomization.ForUrlHelper)
                    .InitializeController(controller);

                controller.Post(form);

                commandHandler.Verify(m =>
                    m.Handle(It.Is(SendCommandBasedOn(form))),
                        Times.Once());
            }
Ejemplo n.º 4
0
            public void ReturnView_WhenModelState_IsInvalid()
            {
                var form = new ForgotPasswordForm
                {
                    EmailAddress = "wrong",
                };
                var controller = new ForgotPasswordController(null);
                controller.ModelState.AddModelError("error", string.Empty);

                var result = controller.Post(form);

                result.ShouldNotBeNull();
                result.ShouldBeType<ViewResult>();
                var viewResult = (ViewResult)result;
                viewResult.Model.ShouldNotBeNull();
                viewResult.Model.ShouldBeType<ForgotPasswordForm>();
                var model = (ForgotPasswordForm)viewResult.Model;
                model.ShouldEqual(form);
                model.EmailAddress.ShouldEqual(form.EmailAddress);
            }
Ejemplo n.º 5
0
            public void FlashesSuccessMessage_UsingModelProperty_EmailAddress()
            {
                var form = new ForgotPasswordForm
                {
                    EmailAddress = "*****@*****.**",
                };
                var commandHandler = new Mock<IHandleCommands<SendConfirmEmailMessageCommand>>
                    (MockBehavior.Strict);
                commandHandler.Setup(m => m.Handle(It.Is(SendCommandBasedOn(form))));
                var services = new ForgotPasswordServices(commandHandler.Object);
                var controller = new ForgotPasswordController(services);
                ReuseMock.TestControllerBuilder(ControllerCustomization.ForUrlHelper)
                    .InitializeController(controller);

                controller.Post(form);

                controller.TempData.ShouldNotBeNull();
                var message = controller.TempData.FeedbackMessage();
                message.ShouldNotBeNull();
                message.ShouldEqual(string.Format(
                    ForgotPasswordController.SuccessMessageFormat,
                        form.EmailAddress));
            }