public void ProductController_Details_isValid() { ProductController controller = new ProductController(); ViewResult result = controller.Details(1) as ViewResult; Product productResult = (Product)result.Model; Assert.AreEqual(1, productResult.productID); }
public void ProductController_Details_isNotValid() { ProductController controller = new ProductController(); HttpNotFoundResult result = controller.Details(9999999) as HttpNotFoundResult; var expectedResult = new HttpNotFoundResult().GetType(); Assert.IsInstanceOfType(result, expectedResult); }
public void ProductController_Create_isNotValid() { Product testProduct = new Product(); testProduct.productBrandName = "invalidTestBrand"; ProductController controller = new ProductController(); controller.ModelState.AddModelError("", "error message"); var result = controller.Create(testProduct) as ViewResult; Product resultProduct = (Product)result.Model; Assert.AreEqual("invalidTestBrand", resultProduct.productBrandName); }
public void ProductController_Create_isValid() { Product testProduct = new Product(); testProduct.productBrandName = "testBrand"; testProduct.productCostPrice = 1; testProduct.productRetailPrice = 2; testProduct.productQty = 5; ProductController controller = new ProductController(); var result = (RedirectToRouteResult)controller.Create(testProduct); Assert.AreEqual("Index", result.RouteValues["action"]); }
public void ProductController_Index() { ProductController controller = new ProductController(); ViewResult result = controller.Index() as ViewResult; Assert.IsNotNull(result.Model); }
public void ProductController_GetProductPrice_isValid() { ProductController controller = new ProductController(); JsonResult result = controller.GetProductPrice(1); Assert.IsNotNull(result); }