void ColumnPost_InvalidId_DisplaysErrorPage() { var mock = new Mock <IColumnRepository>(); mock.Setup(x => x.ColumnPosts).Returns(new ColumnPost[] { new ColumnPost { Id = 1 } }.AsQueryable); var columnController = new ColumnController(mock.Object, null); var result = (RedirectToActionResult)columnController.ColumnPost(2); Assert.Equal("Error", result.ControllerName); Assert.Equal("ColumnPost", result.ActionName); }
void ColumnPost_ValidId_DisplaysViewWithCorrectModel() { var mock = new Mock <IColumnRepository>(); mock.Setup(x => x.ColumnPosts).Returns(new ColumnPost[] { new ColumnPost { Id = 1 } }.AsQueryable); var columnController = new ColumnController(mock.Object, null); var result = (ViewResult)columnController.ColumnPost(1); var model = (ColumnPost)result.Model; Assert.Equal(1, model.Id); Assert.NotNull(model.Comments); Assert.Equal(nameof(columnController.ColumnPost), result.ViewName); }