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); }
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"); }