public void TestCreateManafacturerSubmit()
 {
     var adminController = new AdminController(_manafacturerRepository, _productRepository, _reviewRepository, _submitterRepository);
     var result = (RedirectResult) adminController.AddNewManafacturer(new ManafacturerViewModel
     {
         ManafacturerName = "TestManafacturer 6",
         ManafacturerWebsite = "www.testco6.co.uk"
     });
     if (result != null)
     {
         Assert.AreEqual("/Admin/Index", result.Url);
     }
 }
        public void TestCreateManafacturerView()
        {
            var adminController = new AdminController(_manafacturerRepository, _productRepository, _reviewRepository, _submitterRepository);
            var result = adminController.AddNewManafacturer() as ViewResult;
            if (result != null)
            {
                var createManafacturerResult = (ManafacturerViewModel)result.ViewData.Model;
                Assert.AreEqual(0, createManafacturerResult.ManafacturerId);
                Assert.IsNullOrEmpty(createManafacturerResult.ManafacturerName);
                Assert.IsNullOrEmpty(createManafacturerResult.ManafacturerWebsite);

            }
        }
        public void TestManafacturerListView()
        {
            var adminController = new AdminController(_manafacturerRepository, _productRepository, _reviewRepository, _submitterRepository);
            var result = adminController.Index(new GridSortOptions(), 1) as ViewResult;
            if (result != null)
            {
                var manafacturerListResult = (ManafacturerListViewModel)result.ViewData.Model;
                Assert.AreEqual(5, manafacturerListResult.ManafacturerListRows.Count());

                Assert.IsTrue(IsInManafacturerCollection(_manafacturers[0], manafacturerListResult.ManafacturerListRows));
                Assert.IsTrue(IsInManafacturerCollection(_manafacturers[1], manafacturerListResult.ManafacturerListRows));
                Assert.IsTrue(IsInManafacturerCollection(_manafacturers[2], manafacturerListResult.ManafacturerListRows));
                Assert.IsTrue(IsInManafacturerCollection(_manafacturers[3], manafacturerListResult.ManafacturerListRows));
                Assert.IsTrue(IsInManafacturerCollection(_manafacturers[4], manafacturerListResult.ManafacturerListRows));

            }
        }
 public void TestViewManafacturerDetails()
 {
     var adminController = new AdminController(_manafacturerRepository, _productRepository, _reviewRepository, _submitterRepository);
     var result =  adminController.ViewManafacturer(1) as ViewResult;
     if (result != null)
     {
         var manafacturerViewResult = (ManafacturerViewModel) result.ViewData.Model;
         Assert.AreEqual(manafacturerViewResult.ManafacturerId, _manafacturers[0].ManafacturerId);
         Assert.AreEqual(manafacturerViewResult.ManafacturerName, _manafacturers[0].Name);
         Assert.AreEqual(manafacturerViewResult.ManafacturerWebsite, _manafacturers[0].Website);
         Assert.IsTrue(IsInProductCollection(_products[0], manafacturerViewResult.ProductListRows));
     }
 }
 public void TestEditProductSave()
 {
     var adminController = new AdminController(_manafacturerRepository, _productRepository, _reviewRepository, _submitterRepository);
     var result = (RedirectResult) adminController.EditProduct(new ProductViewModel
                                                                   {
                                                                       ProductId = 1,
                                                                       ProductCode = "Test101Edit",
                                                                       ProductName = "TestProduct101Edit",
                                                                       Price = 10101,
                                                                       Description = "Testing product 1 edit",
                                                                       ManafacturerName = "TestManafacturer 1",
                                                                   }
                                                                   );
     if (result != null)
     {
         Assert.AreEqual("/Admin/ViewManafacturer?id=1", result.Url);
     }
 }
 public void TestEditProduct()
 {
     var adminController = new AdminController(_manafacturerRepository, _productRepository, _reviewRepository, _submitterRepository);
     var result = adminController.EditProduct(1) as ViewResult;
     if (result != null)
     {
         var editProductResult = (ProductViewModel) result.ViewData.Model;
         Assert.AreEqual("Test101", editProductResult.ProductCode);
         Assert.AreEqual("TestProduct101", editProductResult.ProductName);
         Assert.AreEqual(101, editProductResult.Price);
         Assert.AreEqual("Testing product 1", editProductResult.Description);
         Assert.AreEqual("TestManafacturer 1", editProductResult.ManafacturerName);
     }
 }
 public void TestEditManafacturerSave()
 {
     var adminController = new AdminController(_manafacturerRepository, _productRepository, _reviewRepository, _submitterRepository);
     var result = (RedirectResult)adminController.EditManafacturer(new ManafacturerViewModel
     {
         ManafacturerId = 1,
         ManafacturerName = "TestManafacturer 1 edit",
         ManafacturerWebsite = "www.testco1.co.uk_edit"
     });
     if (result != null)
     {
         Assert.AreEqual("/Admin/ViewManafacturer?id=1", result.Url);
     }
 }
 public void TestEditManafacturer()
 {
     var adminController = new AdminController(_manafacturerRepository, _productRepository, _reviewRepository, _submitterRepository);
     var result = adminController.EditManafacturer(1) as ViewResult;
     if (result != null)
     {
         var editProductResult = (ManafacturerViewModel)result.ViewData.Model;
         Assert.AreEqual("TestManafacturer 1", editProductResult.ManafacturerName);
         Assert.AreEqual("www.testco1.co.uk", editProductResult.ManafacturerWebsite);
     }
 }
 public void TestCreateProductView()
 {
     var adminController = new AdminController(_manafacturerRepository, _productRepository, _reviewRepository, _submitterRepository);
     var result = adminController.CreateProduct(1) as ViewResult;
     if (result != null)
     {
         var createProductResult = (ProductViewModel)result.ViewData.Model;
         Assert.AreEqual(0, createProductResult.ProductId);
         Assert.IsNullOrEmpty(createProductResult.ProductCode);
         Assert.IsNullOrEmpty(createProductResult.ProductName);
         Assert.IsNullOrEmpty(createProductResult.Description);
         Assert.AreEqual(0, createProductResult.Price);
         Assert.AreEqual(0, createProductResult.AverageRating);
         Assert.AreEqual(0, createProductResult.TotalReviewRows);
         Assert.AreEqual("TestManafacturer 1", createProductResult.ManafacturerName);
         Assert.AreEqual("TestManafacturer 1", createProductResult.ManafacturerNames[0]);
         Assert.AreEqual("TestManafacturer 2", createProductResult.ManafacturerNames[1]);
         Assert.AreEqual("TestManafacturer 3", createProductResult.ManafacturerNames[2]);
         Assert.AreEqual("TestManafacturer 4", createProductResult.ManafacturerNames[3]);
         Assert.AreEqual("TestManafacturer 5", createProductResult.ManafacturerNames[4]);
     }
 }