示例#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
文件: BlogTest.cs 项目: kimsandin/TDD
        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");
        }
示例#3
0
文件: BlogTest.cs 项目: kimsandin/TDD
        public void PageBeeingPublishedShouldNotSucceedNoUserIsLoggedIn(string title, string content)
        {
            blog = new Blog(_authenticator = new MockAuthenticator());

            var userIsLoggedIn = blog.UserIsLoggedIn;

            Assert.IsFalse(userIsLoggedIn, "User login should not be successful");
            if (userIsLoggedIn)
            {
                //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");
            }
        }
示例#4
0
        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");
        }
示例#5
0
文件: BlogTest.cs 项目: kimsandin/TDD
        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");
        }