public void PublishPageShouldFail(string username, string password, string title, string content) { blog = new Blog(_authenticator = new MockAuthenticator()); blog.LoginUser(new User(username) { Password = password }); var userIsLoggedIn = blog.UserIsLoggedIn; //Check to see that user is really logged in Assert.That(userIsLoggedIn == true, "User should be logged in"); //Instead of page, send in null Assert.Throws <IncorrectPageException>(() => blog.PublishPage(null), "The publish should not have been succesful"); blog.LogoutUser(new User(username) { Password = password }); userIsLoggedIn = blog.UserIsLoggedIn; //Check to see that user is really logged out Assert.That(userIsLoggedIn == false, "User should be logged in"); //Publish page when user is not logged in Assert.That(blog.PublishPage(new Page { Title = title, Content = content }) == false, "The user is not logged in, publish should fail"); }
public void IfNoUserIsLoggedInWhenLoggingOutShouldThrowException(string username, string password) { blog = new Blog(_authenticator = new MockAuthenticator()); Assert.Throws <NoUserLoggedInException>(() => blog.LogoutUser(new User(username) { Password = password })); }
public void UserWillBeLoggedOut(string username, string password) { blog = new Blog(_authenticator = new MockAuthenticator()); blog.LogoutUser(new User(username) { Password = password }); Assert.That(blog.UserIsLoggedIn == false); }
public void LogoutShouldSucceed(string username, string password) { blog = new Blog(_authenticator = new MockAuthenticator()); blog.LoginUser(new User(username) { Password = password }); blog.LogoutUser(new User(username) { Password = password }); Assert.That(blog.UserIsLoggedIn == false); }
public void LogoutShouldThrowException(string username, string password) { blog = new Blog(_authenticator = new MockAuthenticator()); blog.LoginUser(new User(username) { Password = password }); Assert.Throws <IncorrectUserException>(() => blog.LogoutUser(null)); Assert.Throws <IncorrectUserException>(() => blog.LogoutUser(new User(null) { Password = password })); Assert.Throws <IncorrectAuthenticationException>(() => blog.LogoutUser(new User(username) { Password = null })); Assert.Throws <IncorrectUserException>(() => blog.LogoutUser(new User("") { Password = "" })); }
public void OnLogoutIfUserIsNullShouldThrowException() { blog = new Blog(_authenticator = new MockAuthenticator()); Assert.Throws <NoUserExistsException>(() => blog.LogoutUser(null), "Did not throw an exception"); }