Пример #1
0
        public void Index_HasCorrectModelType_CatalogList()
        {
            //Arrange
            CatalogsController controller = new CatalogsController();
            ViewResult         indexView  = controller.Index() as ViewResult;

            //Act
            var result = indexView.ViewData.Model;

            //Assert
            Assert.IsInstanceOfType(result, typeof(List <Catalog>));
        }
Пример #2
0
        public async Task Index_ReturnsExpectedCatalogs()
        {
            // Arrange
            serviceMoq.Setup(x => x.GetCatalogsAsync()).ReturnsAsync(GetTestCatalogs);
            CatalogsController controller = new CatalogsController(serviceMoq.Object);
            var moqCatalogsCount          = GetTestCatalogs().Count;

            // Act
            var result = await controller.Index();

            var viewResult = result as ViewResult;
            var model      = viewResult.Model as List <Catalog>;

            // Assert
            Assert.NotNull(viewResult);
            Assert.NotNull(model);
            Assert.Equal(model.Count, moqCatalogsCount);
        }