public void test_create()
        {
            var controller = new CategoriesController(new CategoryBLL(new CategoryStub()));

            var result = (ViewResult)controller.Create();

            Assert.AreEqual(result.ViewName, "");
        }
        public void test_edit1()
        {
            var controller = new CategoriesController(new CategoryBLL(new CategoryStub()));

            var cat = new Category()
            {
                CategoryId = 1,
                Name = "HelloMon"
            };

            var result = (ViewResult)controller.Edit(1);
            var resultProd = (Category)result.Model;

            Assert.AreEqual(resultProd.Name, cat.Name);
            Assert.AreEqual(result.ViewName, "");
        }
        public void test_index()
        {
            var controller = new CategoriesController(new CategoryBLL(new CategoryStub()));

            var list = new List<Category>();
            var cat = new Category()
            {
                CategoryId = 1,
                Name = "HelloMon"
            };
            list.Add(cat);
            list.Add(cat);
            list.Add(cat);

            var result = (ViewResult)controller.Index();
            var resultList = (List<Category>)result.Model;

            Assert.AreEqual(result.ViewName, "");
            Assert.AreEqual(resultList.First().CategoryId, list.First().CategoryId);
        }
        public void test_post_edit2()
        {
            var controller = new CategoriesController(new CategoryBLL(new CategoryStub()));

            Category prod = null;
            controller.ViewData.ModelState.AddModelError("name", "No category name");

            var result = (ViewResult)controller.Edit(prod);

            Assert.IsTrue(result.ViewData.ModelState.Count == 1);
            Assert.AreEqual(result.ViewName, "");
        }
        public void test_post_edit()
        {
            var controller = new CategoriesController(new CategoryBLL(new CategoryStub()));

            var cat = new Category()
            {
                CategoryId = 1,
                Name = "HelloMon"
            };

            var result = (RedirectToRouteResult)controller.Edit(cat);

            Assert.AreEqual(result.RouteName, "");
            Assert.AreEqual(result.RouteValues.Values.First(), "Index");
        }
        public void test_post_create2()
        {
            var controller = new CategoriesController(new CategoryBLL(new CategoryStub()));

            var cat = new Category();
            controller.ViewData.ModelState.AddModelError("name", "No category name");

            var result = (ViewResult)controller.Create(cat);

            Assert.IsTrue(result.ViewData.ModelState.Count == 1);
            Assert.AreEqual(result.ViewName, "");
        }