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 IfUserIsNullShouldThrowException() { blog = new Blog(_authenticator = new MockAuthenticator()); //TODO Change to custom exception Assert.Throws <IncorrectUserException>(() => blog.LoginUser(null), "Did not throw exception"); }
public void IfUserIsNullShouldThrowException() { //Act blog = new Blog(_authenticator = new MockAuthenticator()); //Assert Cast exception if null Assert.Throws <NoUserNameGivenException>(() => blog.LoginUser(null), "Did not throw an exception"); }
public void IfNoUserIsFoundInDbShouldThrowException(string username, string password) { blog = new Blog(_authenticator = new MockAuthenticator()); Assert.Throws <NoUserFoundInDbException>(() => blog.LoginUser(new User(username) { Password = password }), "Did not throw exception"); }
public void IfUsernameIsNullOrEmptyShouldThrowException(string username, string password) { blog = new Blog(_authenticator = new MockAuthenticator()); Assert.Throws <IncorrectUserException>(() => blog.LoginUser(new User(username) { Password = password }), "Did not throw exception"); }
public void UserIsFoundInDbSuccess(string username, string password) { blog = new Blog(_authenticator = new MockAuthenticator()); blog.LoginUser(new User(username) { Password = password }); var userIsLoggedIn = blog.UserIsLoggedIn; Assert.IsTrue(userIsLoggedIn, "The user should be logged in"); }
public void LogoutShouldFail(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 IfMailContentIsNullOrEmptySendEmailThrowException(string username, string password, string address, string caption, string body) { 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"); Assert.Throws <IncorrectEmailException>(() => blog.SendEmail(address, caption, body)); }
public void PageBeeingPublishedShouldNotSucceedIfPageObjectNotValid(string username, string password, string title, string content) { blog = new Blog(_authenticator = new MockAuthenticator()); //Loggar in anv. först och kollar att det lyckades blog.LoginUser(new User(username) { Password = password }); var userIsLoggedIn = blog.UserIsLoggedIn; Assert.IsTrue(userIsLoggedIn, "User login should be successful"); //Skapa Page-objektet misslyckas när null skickas med Assert.Throws <PageIsNotCorrectObjektException>(() => blog.PublishPage(null), "The publish should not have been succesful"); }
public void IfMailContentIsOKShouldSendEmail(string username, string password, string address, string caption, string body) { 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"); var intreturned = blog.SendEmail(address, caption, body); Assert.That(intreturned == 1, "Message should be sent"); }
public void IfUserIsLoggedInSendEmailShouldReturnOne(string address, string caption, string body, string username, string password) { 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"); var result = blog.SendEmail(address, caption, body); // SendEmail returns 1 if email is sent and 0 on failure. Assert.That(result == 1, "The message should have been sent, since user is logged in"); }
public void PublishPageShouldSucceed(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"); Assert.That(blog.PublishPage(new Page() { Title = title, Content = content }) == true, "The publish should have been succesful"); }
public void PageBeeingPublishedShouldSucceed(string username, string password, string title, string content) { blog = new Blog(_authenticator = new MockAuthenticator()); //Loggar in anv. först och kollar att det lyckades blog.LoginUser(new User(username) { Password = password }); var userIsLoggedIn = blog.UserIsLoggedIn; Assert.IsTrue(userIsLoggedIn, "User login should be successful"); //Skapa Page-objektet och kollar att det är ok och publicerat Assert.That(blog.PublishPage(new Page() { Title = title, Content = content }) == true, "The new page should be successfully published"); }
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 = "" })); }