private Delete ( |
||
model | ||
return | System.Web.Mvc.ActionResult |
public void Delete() { // Arrange CommentController controller = new CommentController(); TestControllerBuilder builder = new TestControllerBuilder(); builder.InitializeController(controller); var id = RepositoryFactory.Command<ICommentData>().GetAllForAdmin() .OrderBy(item => item.Name) .ToPage(1, 1).First().Id; // Act ActionResult result = controller.Delete(id); // Assert var model = result.AssertViewRendered().WithViewData<CommentCRUDModel>(); Assert.AreEqual(id, model.Id); }
public void Delete_post_success() { // Arrange CommentController controller = new CommentController(); TestControllerBuilder builder = new TestControllerBuilder(); builder.InitializeController(controller); var data = RepositoryFactory.Command<ICommentData>().GetAllForAdmin() .OrderBy(item => item.Name); var count = data.Count(); var dataModel = RepositoryFactory.Command<ICommentCrud>().FindByPk(data.ToPage(1, 1).First().Id); // Act ActionResult result = controller.Delete(dataModel); // Assert result.AssertActionRedirect().ToAction("Index"); Assert.AreEqual(count - 1, data.Count()); }