public void CreateTestInvalidStateModel()
        {
            // Arrange
            db = new touch_for_foodEntities();
            Menu_CategoryController target = new Menu_CategoryController(db);
            target.ModelState.AddModelError("error", "ModelState is invalid");
            SelectList expectedMenuList = new SelectList(db.menus, "id", "name", menuCategory1.menu_id);
            SelectList expectedCategoryList = new SelectList(db.categories, "id", "name", menuCategory1.category_id);

            ViewResult actual;

            // Act
            actual = (ViewResult)target.Create(menuCategory1);

            // Assert
            SelectList actualMenuList = actual.ViewBag.menu_id;
            Assert.AreEqual(expectedMenuList.GetType(), actualMenuList.GetType());
            Assert.AreEqual(expectedMenuList.Count(), actualMenuList.Count());

            SelectList actualCategoryList = actual.ViewBag.category_id;
            Assert.AreEqual(expectedCategoryList.GetType(), actualCategoryList.GetType());
            Assert.AreEqual(expectedCategoryList.Count(), actualCategoryList.Count());

            string errorMsg = actual.ViewBag.Error;
            Assert.IsNotNull(errorMsg); //error message is sent to view
        }
        public void CreateViewTest()
        {
            //Arrange
            db = new touch_for_foodEntities();
            Menu_CategoryController target = new Menu_CategoryController(db);
            SelectList mcList = new SelectList(db.categories, "id", "name");
            SelectList menuList = new SelectList(db.menus, "id", "name");

            //Act
            var actual = (ViewResult)target.Create();

            //Assert
            Assert.AreEqual(mcList.GetType(), actual.ViewBag.category_id.GetType());
            Assert.AreEqual(menuList.GetType(), actual.ViewBag.menu_id.GetType());
        }
        public void CreateTest()
        {
            //Arrange
            db = new touch_for_foodEntities();
            Menu_CategoryController target = new Menu_CategoryController(db);
            int numberOfMenuCategoriesBefore = db.categories.Find(category1.id).menu_category.ToList<menu_category>().Count();
            menu_category menuCategory2 = new menu_category();
            menuCategory2.is_active = false;
            menuCategory2.category_id = category1.id;
            menuCategory2.menu_id = menu1.id;

            //Act
            target.Create(menuCategory2);

            //Assert
            db = new touch_for_foodEntities();
            int numberOfMenuCategoriesAfter = db.categories.Find(category1.id).menu_category.ToList<menu_category>().Count();
            Assert.AreEqual((numberOfMenuCategoriesBefore + 1), numberOfMenuCategoriesAfter);
        }