Beispiel #1
0
        public void Get_Create_Action_Creates_CreationView()
        {
            var homeController = new HomeController();
            var result = homeController.Create() as ViewResult;
            var model = result.Model as BlogEntry;

            Assert.AreEqual(string.Empty, model.Title);
        }
Beispiel #2
0
        public void DefaultView_Should_Return_BlogEntries()
        {
            var homeController = new HomeController();
            homeController.Create(new BlogEntry("My BlogEntry"));
            var result = homeController.Index() as ViewResult;

            var entries = result.Model as IEnumerable<BlogEntry>;
            Assert.That(entries.Count(), Is.GreaterThan(0));
        }
Beispiel #3
0
        public void Details_View_Should_Return_Blog_Entry()
        {
            var homeController = new HomeController();

            homeController.Create(new BlogEntry("UniqueTitle"));
            var result = homeController.Detail("UniqueTitle");
            var blogEntry = result.Model as BlogEntry;

            Assert.AreEqual("UniqueTitle", blogEntry.Title);
        }
Beispiel #4
0
        public void Get_Edit_View_Should_Return_Edit_View()
        {
            var homeController = new HomeController();
            homeController.Create(new BlogEntry("UniqueTitle"));
            var result = homeController.Edit("UniqueTitle") as ViewResult;
            var blogEntry = result.Model as BlogEntry;

            Assert.AreEqual("UniqueTitle", blogEntry.Title);
        }
Beispiel #5
0
 public void Post_Edit_Should_Update_Blog_Model()
 {
     var homeController = new HomeController();
     homeController.Create(new BlogEntry("UniqueTitle"));
     var blogEntry = HomeController.currentBlog.Entries.First();
     blogEntry.Body = "My Body";
     homeController.Edit(blogEntry);
     Assert.That(HomeController.currentBlog.Entries.First().Body, Is.EqualTo("My Body"));
 }
Beispiel #6
0
        public void Post_Create_Action_Added_Blog_Entry_To_Blog()
        {
            var homeController = new HomeController();
            var blog = HomeController.currentBlog;

            var model = new BlogEntry(string.Empty);

            Assert.AreEqual(string.Empty, model.Title);

            model.Title = "My Title";
            model.Body = "My Body";

            var result = homeController.Create(model) as ViewResult;

            Assert.That(blog.Entries.Count(), Is.GreaterThan(0));
        }