Пример #1
0
        public void TestIndex()
        {
            var db         = new CsK23T3bEntities();
            var controller = new ProductManagerController();
            var result     = controller.Index();
            var view       = result as ViewResult;

            Assert.IsNotNull(view);
            var model = view.Model as List <ProductTable>;

            Assert.AreEqual(db.ProductTables.Count(), model.Count);
        }
Пример #2
0
        public void ReturnIndexWithProducts()
        {
            _mockProductRepository.Setup(products => products.Collection()).Returns(GetProducts());

            _sut = new ProductManagerController(_mockProductRepository.Object, _mockProductCategoryRepository.Object,
                                                _mockEnvironment.Object);

            IActionResult result = _sut.Index();

            var viewResult = Assert.IsType <ViewResult>(result);

            var model = Assert.IsType <List <Product> >(viewResult.Model);

            Assert.Equal(2, model.Count);

            Assert.Equal("White sneakers", model[0].Description);
            Assert.Equal("Black sneakers", model[1].Description);
        }