示例#1
0
        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");
        }
示例#2
0
        public void IfNoUserIsLoggedInWhenLoggingOutShouldThrowException(string username, string password)
        {
            blog = new Blog(_authenticator = new MockAuthenticator());

            Assert.Throws <NoUserLoggedInException>(() => blog.LogoutUser(new User(username)
            {
                Password = password
            }));
        }
示例#3
0
文件: BlogTest.cs 项目: kimsandin/TDD
        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);
        }
示例#4
0
        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);
        }
示例#5
0
        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 = ""
            }));
        }
示例#6
0
文件: BlogTest.cs 项目: kimsandin/TDD
        public void OnLogoutIfUserIsNullShouldThrowException()
        {
            blog = new Blog(_authenticator = new MockAuthenticator());

            Assert.Throws <NoUserExistsException>(() => blog.LogoutUser(null), "Did not throw an exception");
        }