Exemplo n.º 1
0
        public void TestIndex()
        {
            var prod1 = new ProductModel {
                ProductId = 4, ProductName = "MVVM Book", CategoryId = 1, Description = "MVVM Book", UnitPrice = 199M
            };
            var prod2 = new ProductModel {
                ProductId = 5, ProductName = "MVVM Book New", CategoryId = 1, Description = "MVVM Book New", UnitPrice = 199M
            };

            ProductModelList.Add(prod1);
            uow.Setup(u => u.ProductRepo.GetAllProducts()).Returns(ProductModelList);
            var result = ctrl.Index() as ViewResult;
            var model  = result.Model as List <ProductModel>;

            Assert.Equal(4, model.Count);
            Assert.Contains(prod1, model);
            Assert.DoesNotContain(prod2, model);
        }
Exemplo n.º 2
0
        public void TestIndex()
        {
            var prod1 = new ProductModel {
                ProductId = 4, ProductName = "MVVM Book", CategoryId = 1, Description = "MVVM Book", UnitPrice = 199M
            };
            var prod2 = new ProductModel {
                ProductId = 5, ProductName = "MVVM Book New", CategoryId = 1, Description = "MVVM Book New", UnitPrice = 199M
            };

            ProductModelList.Add(prod1);
            A.CallTo(() => uow.ProductRepo.GetAllProducts()).Returns(ProductModelList);
            var result = ctrl.Index() as ViewResult;
            var model  = result.Model as List <ProductModel>;

            Assert.AreEqual(model.Count, 4);
            CollectionAssert.Contains(model, prod1);
            CollectionAssert.DoesNotContain(model, prod2);
        }