Exemplo n.º 1
0
        void Author_DisplaysViewWithCorrectModel(ColumnPost[] columnPosts, Author[] authors)
        {
            var mock = new Mock <IColumnRepository>();

            mock.Setup(x => x.ColumnPosts).Returns(columnPosts.AsQueryable());
            mock.Setup(x => x.Authors).Returns(authors.AsQueryable());
            var columnController = new ColumnController(mock.Object, null);

            var result = (ViewResult)columnController.Author(1);
            var model  = (AuthorPageViewModel)result.Model;

            Assert.Equal(1, model.Author.Id);
            Assert.Equal(2, model.Columns.Count);
            Assert.Equal(1, model.Columns[0].Id);
            Assert.Equal(2, model.Columns[1].Id);
            Assert.Equal(nameof(columnController.Author), result.ViewName);
        }