Post() 개인적인 메소드

private Post ( ForgotPasswordForm model ) : System.Web.Mvc.ActionResult
model ForgotPasswordForm
리턴 System.Web.Mvc.ActionResult
예제 #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);
            }
예제 #2
0
            public void Returns404_WhenModel_IsNull()
            {
                var controller = new ForgotPasswordController(null);

                var result = controller.Post(null);

                result.ShouldNotBeNull();
                result.ShouldBeType<HttpNotFoundResult>();
            }
예제 #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());
            }
예제 #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);
            }
예제 #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));
            }