コード例 #1
0
        public void LoginOfInvalidUserShouldReturnViewWithUserData()
        {
            LoginUserViewModel user = new LoginUserViewModel { LoginName = "user", Password = "", RememberMe = true };

            AccountController controller = new AccountController(usersRepositoryMock.Object, webSecurityMock.Object);
            ActionResult actionResult = controller.Login(user);

            Assert.IsInstanceOfType(actionResult, typeof(ViewResult));

            ViewResult viewResult = (ViewResult)actionResult;

            Assert.AreEqual(viewResult.Model, user);
        }
コード例 #2
0
        public void LoginOfRegisteredUserShouldRedirectToHomeIndex()
        {
            webSecurityMock.Setup(t => t.Login("user", "pass", true)).Returns(true);
            LoginUserViewModel user = new LoginUserViewModel { LoginName = "user", Password = "******", RememberMe = true };

            AccountController controller = new AccountController(usersRepositoryMock.Object, webSecurityMock.Object);
            ActionResult actionResult = controller.Login(user);

            Assert.IsInstanceOfType(actionResult, typeof(RedirectToRouteResult));

            RedirectToRouteResult redirect = (RedirectToRouteResult)actionResult;

            Assert.AreEqual(redirect.RouteValues["action"], "index");
            Assert.AreEqual(redirect.RouteValues["controller"], "home");
        }