public void LogOffGet() { // Arrange var authServicesStub = new MockAuthenticationServices(removeAuthCookieHandler: () => { }); var controller = GetAccountController(authenticationServices: authServicesStub); // Act var result = controller.LogOff(_user) as RedirectToRouteResult; // Assert Assert.IsInstanceOfType(result, typeof(RedirectToRouteResult)); }
public void LogOnPost_InValidUser() { // Arrange var authServicesStub = new MockAuthenticationServices(passwordValidator: (x, y) => false); var controller = GetAccountController(authenticationServices: authServicesStub); // Act var result = controller.LogOn(new LogOnModel { UserName = TestUserName, Password = TestPassword }, string.Empty); // Assert Assert.IsInstanceOfType(result, typeof(ViewResult)); }
public void LogOnPost_ValidUserCausesAuthCookie() { // Arrange var cookieWasSet = false; var authServicesMock = new MockAuthenticationServices(passwordValidator: (x, y) => true, setAuthenticationCookieHandler:(x, y) => cookieWasSet = true, userAccount: new MutableUser()); var controller = GetAccountController(authenticationServices: authServicesMock); // Act controller.LogOn(new LogOnModel { UserName = TestUserName, Password = TestPassword }, "/desired/url"); // Assert Assert.IsTrue(cookieWasSet); }
public void LogOnPost_ValidUser_EmptyUrl() { // Arrange var authServicesStub = new MockAuthenticationServices(passwordValidator: (x, y) => true, setAuthenticationCookieHandler: (x, y) => { }, userAccount:new MutableUser()); var controller = GetAccountController(authenticationServices: authServicesStub); // Act var result = controller.LogOn(new LogOnModel { UserName = TestUserName, Password = TestPassword }, string.Empty); // Assert Assert.IsInstanceOfType(result, typeof(RedirectToRouteResult)); }
public void LogOffGet_RemovesCookie() { bool cookieRemoveWasCalled = false; // Arrange var authServicesMock = new MockAuthenticationServices(removeAuthCookieHandler: () => cookieRemoveWasCalled = true); var controller = GetAccountController(authenticationServices: authServicesMock); // Act controller.LogOff(_user); // Assert Assert.IsTrue(cookieRemoveWasCalled, "Log off failed to remove the user's cookie."); }