public void RedirectsToLoginReturnPageInTempData_WhenLoginSucceeds() { _session.SetupGet(it => it.IsAuthenticated).Returns(false); _authService.Setup(it => it.Authenticate(_username, _password)).Returns(LoginAttemptResult.Success(_createdAccount)); var loginRedirectPage = new PageRoute("LoginRedirectPage"); var controller = new AuthenticationController(_mockSiteMap, _session.Object, _authService.Object); new AuthenticationTempData(controller.TempData).LoginReturnPage.Store(loginRedirectPage); ActionResult actionResult = controller.Login(_username.ToString(), _password.ToString()); AssertRedirectedTo(actionResult, loginRedirectPage); }
public void RedirectsToLoginPage_WhenLoginFails() { _session.SetupGet(it => it.IsAuthenticated).Returns(false); _authService.Setup(it => it.Authenticate(_username, _password)).Returns(LoginAttemptResult.UsernameNotFound()); var controller = new AuthenticationController(_mockSiteMap, _session.Object, _authService.Object); ActionResult actionResult = controller.Login(_username.ToString(), _password.ToString()); AssertRedirectedTo(actionResult, _mockSiteMap.LoginPage); var authTempData = new AuthenticationTempData(controller.TempData); Assert.That(authTempData.ErrorMessages.Get(), Is.Not.Empty); }