private static IEnumerable<Product> getProductsList(ProductController productController, string category, int page)
 {
     ProductListViewModel productListViewModel = (productController.List(category, page).Model as ProductListViewModel);
     Assert.IsNotNull(productListViewModel);
     return productListViewModel.Products;
 }
 private static int getTotalItemsByCategoryName(ProductController controller, string categoryName)
 {
     var productListViewModel = controller.List(categoryName).Model as ProductListViewModel;
     return productListViewModel != null ? productListViewModel.PagingInfo.TotalItems : 0;
 }
        public void Generate_Category_Specific_Product_Count()
        {
            // Arrange - Create a Mocked Product repository
            Mock<IProductRepository> mockedProductRepository = new Mock<IProductRepository>();
            mockedProductRepository.Setup(m => m.Products).Returns(new[]
                {
                    new Product{ProductID = 1, Name = "P1", Category = "C1"},
                    new Product{ProductID = 1, Name = "P2", Category = "C2"},
                    new Product{ProductID = 1, Name = "P3", Category = "C1"},
                    new Product{ProductID = 1, Name = "P4", Category = "C2"},
                    new Product{ProductID = 1, Name = "P5", Category = "C1"},
                    new Product{ProductID = 1, Name = "P6", Category = "C3"}
                }.AsQueryable());

            // Arrange - Create controller
            ProductController controller = new ProductController(mockedProductRepository.Object);

            // Act
            int c1TotalItems = getTotalItemsByCategoryName(controller, "C1");
            int c2TotalItems = getTotalItemsByCategoryName(controller, "C2");
            int c3TotalItems = getTotalItemsByCategoryName(controller, "C3");

            // Assert
            Assert.AreEqual(3, c1TotalItems);
            Assert.AreEqual(2, c2TotalItems);
            Assert.AreEqual(1, c3TotalItems);
        }