public void AdminController_Has_A_Delete_Post_Post_Method_Which_Accepts_An_Id_And_Deletes_That_Post() { DatabaseHelpers.Initialize(true); var post = new Post(); using (var repository = ObjectFactory.GetInstance<IBlogService>()) { post = DummyLivePost(); repository.Save(post); repository.CommitChanges(); } using (var repository = ObjectFactory.GetInstance<IBlogService>()) { Assert.AreEqual(1, repository.GetPosts().Count); var controller = new AdminController(); var result = controller.DeletePost(post.Id); Assert.AreEqual(0, repository.GetPosts().Count); } }
public void AdminController_Has_A_Delete_Post_Post_Method_Which_Redirects_To_Posts() { DatabaseHelpers.Initialize(true); var post = new Post(); using (var repository = ObjectFactory.GetInstance<IBlogService>()) { post = DummyLivePost(); repository.Save(post); repository.CommitChanges(); } using (var repository = ObjectFactory.GetInstance<IBlogService>()) { Assert.AreEqual(1, repository.GetPosts().Count); var controller = new AdminController(); var result = controller.DeletePost(post.Id) as RedirectToRouteResult; Assert.AreEqual("Posts",result.RouteValues["action"]); } }
public void AdminController_Has_A_Delete_Post_Post_Method_Which_Accepts_An_Id() { DatabaseHelpers.Initialize(true); using (var repository = ObjectFactory.GetInstance<IBlogService>()) { var post = DummyLivePost(); repository.Save(post); repository.CommitChanges(); } var controller = new AdminController(); var result = controller.DeletePost(1); Assert.IsNotNull(result); }