Inheritance: BaseController
            public void ReturnsView_WhenModelState_IsInvalid()
            {
                var services   = CreateSignOnServices();
                var controller = new SignOnController(services);

                controller.ModelState.AddModelError("SomeProperty", "SomeMessage");
                var model = new SignOnForm {
                    EmailAddress = "invalid email"
                };

                var result = controller.Post(model);

                result.ShouldNotBeNull();
                result.ShouldBeType <ViewResult>();
                var viewResult = (ViewResult)result;

                viewResult.ViewName.ShouldEqual(string.Empty);
                viewResult.Model.ShouldNotBeNull();
                viewResult.Model.ShouldBeType <SignOnForm>();
                var form = (SignOnForm)viewResult.Model;

                form.ShouldEqual(model);
                form.EmailAddress.ShouldEqual(model.EmailAddress);
                form.ReturnUrl.ShouldEqual(model.ReturnUrl);
            }
            public void Extends_BaseController()
            {
                var services   = CreateSignOnServices();
                var controller = new SignOnController(services);

                controller.ShouldImplement <BaseController>();
            }
            public void ReturnsView_WhenReturnUrlArg_IsNonEmptyString()
            {
                const string returnUrl  = "/path/to/resource";
                var          userSigner = new Mock <ISignUsers>(MockBehavior.Strict);

                userSigner.Setup(p => p.DefaultSignedOnUrl).Returns("/my/home");
                var services       = CreateSignOnServices();
                var builder        = ReuseMock.TestControllerBuilder(ControllerCustomization.ForUrlHelper);
                var requestContext = new RequestContext(builder.HttpContext, new RouteData());
                var controller     = new SignOnController(services)
                {
                    Url = new UrlHelper(requestContext)
                };

                var result = controller.Get(returnUrl);

                result.ShouldNotBeNull();
                result.ShouldBeType <ViewResult>();
                var viewResult = (ViewResult)result;

                viewResult.ViewName.ShouldEqual(string.Empty);
                viewResult.Model.ShouldNotBeNull();
                viewResult.Model.ShouldBeType <SignOnForm>();
                var form = (SignOnForm)viewResult.Model;

                form.EmailAddress.ShouldBeNull();
                form.ReturnUrl.ShouldEqual(returnUrl);
            }
            public void ReturnsView_WhenReturnUrlArg_IsEmptyString()
            {
                var returnUrl  = string.Empty;
                var services   = CreateSignOnServices();
                var controller = new SignOnController(services);

                var result = controller.Get(returnUrl);

                result.ShouldNotBeNull();
                result.ShouldBeType <ViewResult>();
                var viewResult = (ViewResult)result;

                viewResult.ViewName.ShouldEqual(string.Empty);
                viewResult.Model.ShouldNotBeNull();
                viewResult.Model.ShouldBeType <SignOnForm>();
                var form = (SignOnForm)viewResult.Model;

                form.EmailAddress.ShouldBeNull();
                form.ReturnUrl.ShouldEqual(returnUrl);
            }
            public void ReturnsView_WhenReturnUrlArg_IsNull()
            {
                var services = CreateSignOnServices();
                var builder = ReuseMock.TestControllerBuilder(ControllerCustomization.ForUrlHelper);
                var requestContext = new RequestContext(builder.HttpContext, new RouteData());
                var controller = new SignOnController(services)
                {
                    Url = new UrlHelper(requestContext)
                };

                var result = controller.Get(null);

                result.ShouldNotBeNull();
                result.ShouldBeType<ViewResult>();
                var viewResult = (ViewResult) result;
                viewResult.ViewName.ShouldEqual(string.Empty);
                viewResult.Model.ShouldNotBeNull();
                viewResult.Model.ShouldBeType<SignOnForm>();
                var form = (SignOnForm)viewResult.Model;
                form.EmailAddress.ShouldBeNull();
                form.ReturnUrl.ShouldBeNull();
            }
            public void ReturnsView_WhenReturnUrlArg_IsNull()
            {
                var services       = CreateSignOnServices();
                var builder        = ReuseMock.TestControllerBuilder(ControllerCustomization.ForUrlHelper);
                var requestContext = new RequestContext(builder.HttpContext, new RouteData());
                var controller     = new SignOnController(services)
                {
                    Url = new UrlHelper(requestContext)
                };

                var result = controller.Get(null);

                result.ShouldNotBeNull();
                result.ShouldBeType <ViewResult>();
                var viewResult = (ViewResult)result;

                viewResult.ViewName.ShouldEqual(string.Empty);
                viewResult.Model.ShouldNotBeNull();
                viewResult.Model.ShouldBeType <SignOnForm>();
                var form = (SignOnForm)viewResult.Model;

                form.EmailAddress.ShouldBeNull();
                form.ReturnUrl.ShouldBeNull();
            }
            public void ReturnsView_WhenReturnUrlArg_IsEmptyString()
            {
                var returnUrl = string.Empty;
                var services = CreateSignOnServices();
                var controller = new SignOnController(services);

                var result = controller.Get(returnUrl);

                result.ShouldNotBeNull();
                result.ShouldBeType<ViewResult>();
                var viewResult = (ViewResult)result;
                viewResult.ViewName.ShouldEqual(string.Empty);
                viewResult.Model.ShouldNotBeNull();
                viewResult.Model.ShouldBeType<SignOnForm>();
                var form = (SignOnForm)viewResult.Model;
                form.EmailAddress.ShouldBeNull();
                form.ReturnUrl.ShouldEqual(returnUrl);
            }
 public void Extends_BaseController()
 {
     var services = CreateSignOnServices();
     var controller = new SignOnController(services);
     controller.ShouldImplement<BaseController>();
 }
            public void ReturnsView_WhenModelState_IsInvalid()
            {
                var services = CreateSignOnServices();
                var controller = new SignOnController(services);
                controller.ModelState.AddModelError("SomeProperty", "SomeMessage");
                var model = new SignOnForm { EmailAddress = "invalid email" };

                var result = controller.Post(model);

                result.ShouldNotBeNull();
                result.ShouldBeType<ViewResult>();
                var viewResult = (ViewResult)result;
                viewResult.ViewName.ShouldEqual(string.Empty);
                viewResult.Model.ShouldNotBeNull();
                viewResult.Model.ShouldBeType<SignOnForm>();
                var form = (SignOnForm)viewResult.Model;
                form.ShouldEqual(model);
                form.EmailAddress.ShouldEqual(model.EmailAddress);
                form.ReturnUrl.ShouldEqual(model.ReturnUrl);
            }
            public void ReturnsView_WhenReturnUrlArg_IsNonEmptyString()
            {
                const string returnUrl = "/path/to/resource";
                var userSigner = new Mock<ISignUsers>(MockBehavior.Strict);
                userSigner.Setup(p => p.DefaultSignedOnUrl).Returns("/my/home");
                var services = CreateSignOnServices();
                var builder = ReuseMock.TestControllerBuilder(ControllerCustomization.ForUrlHelper);
                var requestContext = new RequestContext(builder.HttpContext, new RouteData());
                var controller = new SignOnController(services)
                {
                    Url = new UrlHelper(requestContext)
                };

                var result = controller.Get(returnUrl);

                result.ShouldNotBeNull();
                result.ShouldBeType<ViewResult>();
                var viewResult = (ViewResult)result;
                viewResult.ViewName.ShouldEqual(string.Empty);
                viewResult.Model.ShouldNotBeNull();
                viewResult.Model.ShouldBeType<SignOnForm>();
                var form = (SignOnForm)viewResult.Model;
                form.EmailAddress.ShouldBeNull();
                form.ReturnUrl.ShouldEqual(returnUrl);
            }