public void non_admin_category_new_category_httppost()
        {
            //Arrange
            var controller = new CategoryController(new CategoryBLL(new CategoryDALStub()));

            //Act
            var result = (RedirectToRouteResult)controller.newCategory(null);

            //Assert
            Assert.AreEqual("LogIn", result.RouteValues["Action"]);
            Assert.AreEqual("Main", result.RouteValues["Controller"]);
        }
        public void category_new_category_httppost()
        {
            //Arrange
            TestControllerBuilder builder = new TestControllerBuilder();
            var controller = new CategoryController(new CategoryBLL(new CategoryDALStub()));
            builder.InitializeController(controller);
            builder.HttpContext.Session["loggedInUser"] = new Customer() { id = 1, admin = true };
            CategoryInfo c = new CategoryInfo()
            {
                name="en kategori"
            };

            //Act
            var result = (JsonResult)controller.newCategory(c);
            var success = (bool)(new PrivateObject(result.Data, "success")).Target;
            //Assert

            Assert.IsTrue(success);
        }
        public void category_new_category_httppost_modelstate_invalid()
        {
            //Arrange
            TestControllerBuilder builder = new TestControllerBuilder();
            var controller = new CategoryController(new CategoryBLL(new CategoryDALStub()));
            builder.InitializeController(controller);
            builder.HttpContext.Session["loggedInUser"] = new Customer() { id = 1, admin = true };
            controller.ViewData.ModelState.AddModelError("kategori", "Ikke oppgitt kategori");
            CategoryInfo c = new CategoryInfo()
            {
                name = ""
            };

            //Act
            var result = (JsonResult)controller.newCategory(c);
            var success = (bool)(new PrivateObject(result.Data, "success")).Target;

            //Assert
            Assert.IsFalse(success);
            
        }
        public void category_new_category_view()
        {
            //Arrange
            TestControllerBuilder builder = new TestControllerBuilder();
            var controller = new CategoryController(new CategoryBLL(new CategoryDALStub()));
            builder.InitializeController(controller);
            builder.HttpContext.Session["loggedInUser"] = new Customer() { id = 1, admin = true }; 

            //Act
            var action = (ViewResult)controller.newCategory();
           
            var result = (CategoryInfo)action.Model;

            //Assert
            Assert.AreEqual("", action.ViewName);
            Assert.IsNull(result); 
        }