public void PublishPostIsDraftContentNulledTest() { var postRepo = new SimpleRepository<Post>(new InMemoryRepositoryDataSource<Post>(new List<Post> { new Post { Id=1, Status = PostStatus.Draft, DraftTitle = "Test Title", DraftDescription = "Test Description", DraftBody = "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.ConfirmPublish(1, new ConfirmPublishModel()) as JsonResult; Assert.IsNotNull(result); // This requires [assembly: InternalsVisibleTo("StaticVoid.Blog.Site.Tests")] in StaticVoid.Blog.Site so that we can read anon types, needing this is kinda lame // dynamic should just jams it in there by itself. I mean heck the debugger can see it, why cant dynamic? // cf http://stackoverflow.com/questions/2630370/c-sharp-dynamic-cannot-access-properties-from-anonymous-types-declared-in-anot Assert.IsTrue(((dynamic)result.Data).success); Assert.AreEqual(1, postRepo.GetAll().Count()); Assert.IsNull(postRepo.GetAll().First().DraftTitle); Assert.IsNull(postRepo.GetAll().First().DraftDescription); Assert.IsNull(postRepo.GetAll().First().DraftBody); }
public void CantPublishPostWhenItIsntInTheCurrentBlog() { var postRepo = new SimpleRepository<Post>(new InMemoryRepositoryDataSource<Post>(new List<Post> { new Post { Id=1, Status = PostStatus.Draft, DraftTitle = "Test Title", DraftDescription = "Test Description", DraftBody = "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 MockDateTimeProvider(new DateTime(2013, 4, 27, 1, 2, 3)), _mockHttpContext.Object); try { sut.ConfirmPublish(1, new ConfirmPublishModel()); Assert.Fail("Was expecting an exception when trying to edit"); } catch { } // This requires [assembly: InternalsVisibleTo("StaticVoid.Blog.Site.Tests")] in StaticVoid.Blog.Site so that we can read anon types, needing this is kinda lame // dynamic should just jams it in there by itself. I mean heck the debugger can see it, why cant dynamic? // cf http://stackoverflow.com/questions/2630370/c-sharp-dynamic-cannot-access-properties-from-anonymous-types-declared-in-anot Assert.AreEqual(1, postRepo.GetAll().Count()); Assert.AreEqual(0, _postModificationRepo.GetAll().Count()); Assert.AreEqual(PostStatus.Draft, postRepo.GetAll().First().Status); }