public void non_admin_product_product_details_httppost()
        {
            //Arrange
            var controller = new ProductController(new ProductBLL(new ProductDALStub()));

            //Act
            var result = (RedirectToRouteResult)controller.ProductDetails(0,null);

            //Assert
            Assert.AreEqual("LogIn", result.RouteValues["Action"]);
            Assert.AreEqual("Main", result.RouteValues["Controller"]);
        }
        public void product_update_detail_HTTPPOST_modelState_Is_INValid()
        {
            // Arrange
            TestControllerBuilder builder = new TestControllerBuilder();

            var controller = new ProductController(new ProductBLL(new ProductDALStub()));
            builder.InitializeController(controller);
            builder.HttpContext.Session["loggedInUser"] = new Customer() { id = 1, admin = true };
            controller.ViewData.ModelState.AddModelError("feil", "dette ble feil gitt");
            ProductDetail expected = new ProductDetail()
            {
                itemnumber = 1,
                name = "Tullball",
                description = "Hei",
                price = 123,
                volum = 50,
                producerid = 2,
                longDescription = "Tullball er et fantastisk godt drikkeprodukt",
                subCategoryid = 3,
                countryid = 1
            };

            // Act
            var result = (JsonResult)controller.ProductDetails(1, expected);
            var success = (bool)(new PrivateObject(result.Data, "success")).Target;

            //Assert
            Assert.IsFalse(success);
        }
        public void product_detail_view()
        {
            // Arrange
            TestControllerBuilder builder = new TestControllerBuilder();

            var controller = new ProductController(new ProductBLL(new ProductDALStub()));
            builder.InitializeController(controller);
            builder.HttpContext.Session["loggedInUser"] = new Customer() { id = 1, admin = true };

            ProductDetail expected = new ProductDetail()
            {
                itemnumber = 1,
                name = "Tullball",
                description = "Hei",
                price = 123,
                volum = 50,
                producerid = 2,
                longDescription = "Tullball er et fantastisk godt drikkeprodukt",
                subCategoryid = 3,
                countryid = 1
            };

            // Act
            var action = (ViewResult)controller.ProductDetails(expected.itemnumber);
            var result = (ProductDetail)action.Model;

            // Assert
            Assert.AreEqual(expected.itemnumber, result.itemnumber);
            Assert.AreEqual(expected.name, result.name);
            Assert.AreEqual(expected.description, result.description);
            Assert.AreEqual(expected.price, result.price);
            Assert.AreEqual(expected.volum, result.volum);
            Assert.AreEqual(expected.producerid, result.producerid);
            Assert.AreEqual(expected.longDescription, result.longDescription);
            Assert.AreEqual(expected.countryid, result.countryid);
        }