public void PostIndexReturnsNullReturnsIndexView()
 {
     _repo.Setup(r => r.GetSubscription("User", "Password")).Returns(() => null);
     var signIn = new SignIn
                      {
                          UserName = "******",
                          Password = "******"
                      };
     var result = _controller.Index(signIn, null) as ViewResult;
     Assert.That(result, Is.Not.Null);
     Assert.That(result.GetModelFromViewResult<SignIn>(), Is.EqualTo(signIn));
     Assert.That(result.ViewName, Is.EqualTo(""));
 }
예제 #2
0
        public ActionResult Index(SignIn signIn, string returnUrl)
        {
            var subscription = _subscriptionRepository.GetSubscription(signIn.UserName, signIn.Password);
            if (subscription != null)
            {
                _formsAuthenticator.SetAuthCookie(subscription.UserName, false);

                if (returnUrl != null && Url.IsLocalUrl(returnUrl) && returnUrl.Length > 1 && returnUrl.StartsWith("/")
                        && !returnUrl.StartsWith("//") && !returnUrl.StartsWith("/\\"))
                {
                    return Redirect(returnUrl);
                }
                return RedirectToAction("Index", "Post");
            }
            return View(signIn);
        }
 public void PostIndexUserWithGoodCredentialsRedirectsToPostIndex()
 {
     _repo.Setup(r => r.GetSubscription("User", "Password"))
         .Returns(() => new Subscription
                         {
                             UserName = "******"
                         });
     var signIn = new SignIn
     {
         UserName = "******",
         Password = "******"
     };
     var result = _controller.Index(signIn, null) as RedirectToRouteResult;
     Assert.That(result, Is.Not.Null);
     Assert.That(result.RouteValues["controller"], Is.EqualTo("Post"));
     Assert.That(result.RouteValues["action"], Is.EqualTo("Index"));
     _formsAuthenticator.Verify(f => f.SetAuthCookie("User", false));
 }