public ActionResult Create(CategoryClass cate)
 {
     if (ModelState.IsValid)
     {
         CategoryList cateList = new CategoryList();
         cateList.AddCategory(cate);
         return(RedirectToAction("Index"));
     }
     return(View());
 }
Example #2
0
        //Checks to see if categories are inserted in order by priority rating
        public void TestAddCategorySorted()
        {
            //Arrange
            CategoryList list = new CategoryList();

            Category firstCategory = new Category("First", 0, 0);

            list.AddCategory(firstCategory);
            Category secondCategory = new Category("Second", 0, 5);

            list.AddCategory(secondCategory);
            Category thirdCategory = new Category("Third", 0, 10);

            list.AddCategory(thirdCategory);

            string expectedtitle = "Second";

            //Actual
            string actualtitle = list.head.next.Data.getCategoryTitle();

            //Assert
            Assert.AreEqual(expectedtitle, actualtitle, "Positive - Expected matches actual");
        }
Example #3
0
        //Checks to see if value returned follows index
        public void TestCategoryExists()
        {
            //Arrange
            CategoryList list = new CategoryList();

            Category firstCategory = new Category("First", 0, 0);

            list.AddCategory(firstCategory);
            Category secondCategory = new Category("Second", 0, 5);

            list.AddCategory(secondCategory);
            Category thirdCategory = new Category("Third", 0, 10);

            list.AddCategory(thirdCategory);

            bool expected = true;

            //Actual
            bool actual = list.categoryExists("First");

            //Assert
            Assert.AreEqual(expected, actual, "Positive - Expected matches actual");
        }
Example #4
0
        //Checks to see if value returned follows index
        public void TestGetCategory()
        {
            //Arrange
            CategoryList list = new CategoryList();

            Category firstCategory = new Category("First", 0, 0);

            list.AddCategory(firstCategory);
            Category secondCategory = new Category("Second", 0, 5);

            list.AddCategory(secondCategory);
            Category thirdCategory = new Category("Third", 0, 10);

            list.AddCategory(thirdCategory);

            Category expected = secondCategory;

            //Actual
            Category actual = list.getCategory(1);

            //Assert
            Assert.AreEqual(expected, actual, "Positive - Expected matches actual");
        }
Example #5
0
        //Checks to see if correct index is returned if list has one Category
        public void TestGetIndexOneItem()
        {
            //Arrange
            CategoryList list         = new CategoryList();
            Category     testCategory = new Category("Test", 0, 0);

            list.AddCategory(testCategory);
            int expected = 0;

            //Actual
            int actual = list.getIndex("Test");

            //Assert
            Assert.AreEqual(expected, actual, 0, "Positive - Expected matches actual");
        }
Example #6
0
        //Checks to see if category is added to empty list properly
        public void TestAddCategoryToEmptyList()
        {
            //Arrange
            CategoryList list          = new CategoryList();
            Category     firstCategory = new Category("First", 0, 0);

            list.AddCategory(firstCategory);
            string expectedtitle = "First";

            //Actual
            string actualtitle = list.head.Data.getCategoryTitle();

            //Assert
            Assert.AreEqual(expectedtitle, actualtitle, "Positive - Expected matches actual");
        }