public void TestProductDetailsViews()
 {
     var productController = new ProductController( _manafacturerRepository, _productRepository, _reviewRepository, _submitterRepository);
     var result = productController.ProductDetails( 1, new GridSortOptions(),  1 ) as ViewResult;
     if (result != null)
     {
         var productDetailsResult = (ProductViewModel) result.ViewData.Model;
         Assert.AreEqual("TestProduct101",productDetailsResult.ProductName);
         Assert.AreEqual("Test101", productDetailsResult.ProductCode);
         Assert.AreEqual(101, productDetailsResult.Price);
         Assert.AreEqual("TestManafacturer 1", productDetailsResult.ManafacturerName);
         Assert.AreEqual("Testing product 1", productDetailsResult.Description);
         Assert.AreEqual(1, productDetailsResult.AverageRating);
         Assert.AreEqual(1, productDetailsResult.TotalReviewRows);
         Assert.AreEqual("TestSubmitter 1", productDetailsResult.ReviewRows.ElementAt(0).SubmitterName);
         Assert.AreEqual(1, productDetailsResult.ReviewRows.ElementAt(0).Rating);
         Assert.AreEqual("TestReview1", productDetailsResult.ReviewRows.ElementAt(0).DetailedReview);
     }
 }
 public void TestReviewSubmitValid()
 {
     var productController = new ProductController(_manafacturerRepository, _productRepository, _reviewRepository, _submitterRepository);
     var result = (RedirectResult) productController.ProductDetails(new ReviewRowModel("TestSubmitter 6", 5, "TestReview6"), 1);
     if (result != null)
     {
         Assert.AreEqual("/Product/ProductDetails/1", result.Url);
     }
 }
 public void TestProductListView()
 {
     var productController = new ProductController(_manafacturerRepository, _productRepository, _reviewRepository, _submitterRepository);
     var result = productController.Index() as ViewResult;
     if (result != null)
     {
         Assert.AreEqual(0, result.ViewData.Count);
     }
 }
 public void TestProductSortSearchDesc()
 {
     var productController = new ProductController(_manafacturerRepository, _productRepository, _reviewRepository, _submitterRepository);
     var result = productController.Sort("ProductCode", 1, "#product_grid", "product/sort/", "DESC", "ProductGrid", "Test") as ViewResult;
     if (result != null)
     {
         var productSearchResult = (IPagination<ProductListViewModelRow>)result.ViewData["ProductListRows"];
         Assert.AreEqual(5, productSearchResult.Count());
         Assert.AreEqual("Test101", productSearchResult.ElementAt(4).ProductCode);
         Assert.AreEqual("Test105", productSearchResult.ElementAt(0).ProductCode);
     }
 }
 public void TestProductListSearchView()
 {
     var productController = new ProductController(_manafacturerRepository, _productRepository, _reviewRepository, _submitterRepository);
     var result = productController.Index("101") as ViewResult;
     if (result != null)
     {
         var productSearchResult = (ProductListViewModel)result.ViewData.Model;
         Assert.AreEqual("101", productSearchResult.SearchWord);
     }
 }