예제 #1
0
        public ActionResult Index()
        {
            var products = service.GetAll(1, 10);
            IEnumerable <ProductView> pv  = AutoMapperHelper.Get <IEnumerable <Product>, IEnumerable <ProductView> >(products);
            ProductViewAll            pva = new ProductViewAll {
                ProductViews = pv, TotalCount = pv.Count()
            };

            return(View("Index", pva));
        }
예제 #2
0
        public void Product_Get_View()
        {
            //Act
            ActionResult result = controller.Index();

            //Assert
            Assert.IsNotNull(result, "View not found");
            service.Verify(s => s.GetAll(1, 10));
            Assert.IsInstanceOf <ViewResult>(result, "Base View Result there ");
            Assert.IsNotNull(((ViewResult)result).Model, "Model is null ");
            Assert.IsTrue(((ViewResult)result).ViewData.Model is ProductViewAll, "ModelAll is not valid");

            var            pvaModel = ((ViewResult)result).Model;
            ProductViewAll pva      = (ProductViewAll)pvaModel;

            Assert.IsNotNull(pva.ProductViews, "Does not contains product views to display");
            Assert.IsTrue(pva.ProductViews is IEnumerable <ProductView>, "Does not contains product views to display");
            Assert.IsNotNull(pva.TotalCount, "Does not contains Total Count to handle paging");
            Assert.IsTrue(pva.TotalCount is int, "Does not contains product views to display");
            //Assert.IsNotNull(controller.ViewBag.Title, "Does not title to set ");
        }