public void EditPostContentTest()
        {
            var postRepo = new SimpleRepository<Post>(new InMemoryRepositoryDataSource<Post>(new List<Post> { 
                new Post { 
                    Id=1, 
                    Status = PostStatus.Published, 
                    Title = "Test Title", 
                    Description = "Test Description", 
                    Body = "Test Body", 
                    Path ="2013/04/9/some-other-post", 
                    Posted = new DateTime(2013,4,9), 
                    Author = new User{ Email = "" },
                    BlogId = 1
                }}));

            PostAuthoringController sut = new PostAuthoringController(
                postRepo,
                _postModificationRepo,
                _userRepo,
                _redirectRepo,
                _securableRepo,
                _blogRepo,
                _mockSecurityHelper.Object,
                new DateTimeProvider(),
                _mockHttpContext.Object);

            var result = sut.Edit(1,new Areas.Manage.Models.PostEditModel { 
                Title = "New Title",
                Body = "New Body",
                Description = "New Description", 
                Reposted = true,
                CanonicalUrl = "http://blog.con/new-post" }) as RedirectToRouteResult;

            Assert.IsNotNull(result);

            Assert.AreEqual("Index", result.RouteValues["action"]);
            Assert.AreEqual("Dashboard", result.RouteValues["controller"]);

            Assert.AreEqual(1, postRepo.GetAll().Count());
            Assert.IsTrue(postRepo.GetAll().Last().HasDraftContent());
            Assert.AreEqual("Test Title", postRepo.GetAll().Last().Title);
            Assert.AreEqual("Test Body", postRepo.GetAll().Last().Body);
            Assert.AreEqual("Test Description", postRepo.GetAll().Last().Description);
            Assert.AreEqual("New Title", postRepo.GetAll().Last().DraftTitle);
            Assert.AreEqual("New Body", postRepo.GetAll().Last().DraftBody);
            Assert.AreEqual("New Description", postRepo.GetAll().Last().DraftDescription);
            Assert.AreEqual("http://blog.con/new-post", postRepo.GetAll().Last().Canonical);//TODO Change this so that its also draft
        }
        public void CannotEditPostWhenNotInCurrentBlog()
        {
            var postRepo = new SimpleRepository<Post>(new InMemoryRepositoryDataSource<Post>(new List<Post> { 
                new Post { 
                    Id=1, 
                    Status = PostStatus.Published, 
                    Title = "Test Title", 
                    Description = "Test Description", 
                    Body = "Test Body", 
                    Path ="2013/04/9/some-other-post", 
                    Posted = new DateTime(2013,4,9), 
                    Author = new User{ Email = "" },
                    BlogId = 2
                }}));

            PostAuthoringController sut = new PostAuthoringController(
                postRepo,
                _postModificationRepo,
                _userRepo,
                _redirectRepo,
                _blogRepo,
                _mockSecurityHelper.Object,
                new DateTimeProvider(),
                _mockHttpContext.Object);

            try
            {
                sut.Edit(1, new Areas.Manage.Models.PostEditModel
                {
                    Title = "New Title",
                    Body = "New Body",
                    Description = "New Description",
                    Reposted = true,
                    CanonicalUrl = "http://blog.con/new-post"
                });
                Assert.Fail("Was expecting an exception when trying to edit");
            }
            catch{}

            Assert.AreEqual(1, postRepo.GetAll().Count());
            Assert.IsFalse(postRepo.GetAll().Last().HasDraftContent());
            Assert.AreEqual("Test Title", postRepo.GetAll().Last().Title);
            Assert.AreEqual("Test Body", postRepo.GetAll().Last().Body);
            Assert.AreEqual("Test Description", postRepo.GetAll().Last().Description);
            Assert.IsNull(postRepo.GetAll().Last().DraftTitle);
            Assert.IsNull(postRepo.GetAll().Last().DraftBody);
            Assert.IsNull(postRepo.GetAll().Last().DraftDescription);
            Assert.IsNull(postRepo.GetAll().Last().Canonical);
        }
        public void EditPostNoChangeDoesNotTriggerDraftStatus()
        {
            var postRepo = new SimpleRepository<Post>(new InMemoryRepositoryDataSource<Post>(new List<Post> { 
                new Post { 
                    Id=1, 
                    Status = PostStatus.Published, 
                    Title = "Test Title", 
                    Description = "Test Description", 
                    Body = "Test Body", 
                    Path ="2013/04/9/some-other-post", 
                    Posted = new DateTime(2013,4,9), 
                    Author = new User{ Email = "" },
                    BlogId = 1
                }}));

            PostAuthoringController sut = new PostAuthoringController(
                postRepo,
                _postModificationRepo,
                _userRepo,
                _redirectRepo,
                _blogRepo,
                _mockSecurityHelper.Object,
                new DateTimeProvider(),
                _mockHttpContext.Object);

            var result = sut.Edit(1, new Areas.Manage.Models.PostEditModel
            {
                Title = "Test Title",
                Body = "Test Body",
                Description = "Test Description",
                Reposted = false,
            }) as RedirectToRouteResult;

            Assert.IsNotNull(result);

            Assert.AreEqual("Index", result.RouteValues["action"]);
            Assert.AreEqual("Dashboard", result.RouteValues["controller"]);

            Assert.AreEqual(1, postRepo.GetAll().Count());
            Assert.IsFalse(postRepo.GetAll().Last().HasDraftContent());
        }