void Index_EmptyPosts_DisplaysViewWithCorrectModel() { var mock = new Mock <IColumnRepository>(); mock.Setup(x => x.ColumnPosts).Returns(new List <ColumnPost>().AsQueryable()); var columnController = new ColumnController(mock.Object, null); var result = (ViewResult)columnController.Index(); var model = (ColumnMainPageViewModel)result.Model; Assert.Equal(5, model.Columns.Count); Assert.Equal(nameof(columnController.Index), result.ViewName); }
void Index_DisplaysViewWithCorrectModel(ColumnPost[] columnPosts, Author[] authors) { var columnRepoMock = new Mock <IColumnRepository>(); columnRepoMock.Setup(x => x.ColumnPosts).Returns(columnPosts.AsQueryable()); var columnController = new ColumnController(columnRepoMock.Object, null); var result = (ViewResult)columnController.Index(); var model = (ColumnMainPageViewModel)result.Model; Assert.Equal(1, model.FirstColumn.Id); Assert.Equal(2, model.Columns.Count); Assert.Equal(2, model.Columns.First().Id); Assert.Equal(nameof(columnController.Index), result.ViewName); }