public void GetCategories_ReturnsAllRecipeCategories_CategoryList()
        {
            //Arrange
            Recipe testRecipe = new Recipe("Popplers", "Freshly laid Omikronian young", "Find fetal Omikronian, consume", 3);

            testRecipe.Save();

            Category testCategory1 = new Category("Home stuff");

            testCategory1.Save();

            Category testCategory2 = new Category("Work stuff");

            testCategory2.Save();

            //Act
            testRecipe.AddCategory(testCategory1);
            List <Category> result   = testRecipe.GetCategories();
            List <Category> testList = new List <Category> {
                testCategory1
            };

            //Assert
            CollectionAssert.AreEqual(testList, result);
        }
Exemple #2
0
        public ActionResult Categorize(int category, int recipe)
        {
            Recipe selectedRecipe = Recipe.Find(recipe);

            selectedRecipe.AddCategory(category, recipe);
            return(RedirectToAction("New"));
        }
Exemple #3
0
        public ActionResult AddTag(int recipeId)
        {
            Recipe   recipe   = Recipe.Find(recipeId);
            Category category = Category.Find(Int32.Parse(Request.Form["category-id"]));

            recipe.AddCategory(category);
            return(RedirectToAction("Index"));
        }
Exemple #4
0
        public ActionResult AddCategory(int recipeId)
        {
            Recipe   recipe   = Recipe.Find(recipeId);
            Category category = Category.Find(Int32.Parse(Request.Form["category-id"]));

            recipe.AddCategory(category);
            return(RedirectToAction("Details", new { id = recipeId }));
        }
        public void GetAllCategories_ReturnsAllCategoriesAttachedToRecipe_CategoryList()
        {
            Recipe testRecipe1 = new Recipe("Fruit Salad", "Fruit", "Eat the fruit.", 5);

            testRecipe1.Save();
            Category testCategory1 = new Category("Low-Effort");

            testCategory1.Save();
            Category testCategory2 = new Category("Meats");

            testCategory2.Save();
            List <Category> testList = new List <Category> {
                testCategory1, testCategory2
            };

            testRecipe1.AddCategory(testCategory1);
            testRecipe1.AddCategory(testCategory2);
            List <Category> resultList = testRecipe1.GetAllCategories();

            CollectionAssert.AreEqual(testList, resultList);
        }
        public void GetCategories_ReturnAllRecipeCategories_CategoriesList()
        {
            Recipe testRecipe = new Recipe("Cow Cake", "Some steps", 4);

            testRecipe.Save();

            Category testCategory1 = new Category("Junk Food");

            testCategory1.Save();
            Category testCategory2 = new Category("Health Food");

            testCategory2.Save();

            testRecipe.AddCategory(testCategory1);
            testRecipe.AddCategory(testCategory2);
            List <Category> result   = testRecipe.GetCategories();
            List <Category> testList = new List <Category> {
                testCategory1, testCategory2
            };

            CollectionAssert.AreEqual(testList, result);
        }
        public void AddCategory_CorrectlyAttatchesCategoryToRecipe_Category()
        {
            Recipe testRecipe1 = new Recipe("Fruit Salad", "Fruit", "Eat the fruit.", 5);

            testRecipe1.Save();
            Category testCategory1 = new Category("Low-Effort");

            testCategory1.Save();
            List <Category> testList = new List <Category> {
                testCategory1
            };

            testRecipe1.AddCategory(testCategory1);
            List <Category> resultList = testRecipe1.GetAllCategories();

            CollectionAssert.AreEqual(testList, resultList);
        }
Exemple #8
0
        public void DeleteRecipe_DeletesRecipeAssociationsFromDatabase_RecipeList()
        {
            Category testCategory = new Category("Mer");

            testCategory.Save();
            Recipe testRecipe = new Recipe("test", 2, "test3", "test4");

            testRecipe.Save();

            testRecipe.AddCategory(testCategory);
            testRecipe.DeleteRecipe();
            List <Recipe> resultCategoryRecipes = testCategory.GetRecipes();
            List <Recipe> testCategoryRecipes   = new List <Recipe> {
            };

            CollectionAssert.AreEqual(testCategoryRecipes, resultCategoryRecipes);
        }
        public void AddCategory_AddsCategoryToRecipe_CategoryList()
        {
            Recipe testRecipe = new Recipe("Cow Cake", "Some steps", 4);

            testRecipe.Save();

            Category testCategory = new Category("Junk Food");

            testCategory.Save();

            testRecipe.AddCategory(testCategory);
            List <Category> result   = testRecipe.GetCategories();
            List <Category> testList = new List <Category> {
                testCategory
            };

            CollectionAssert.AreEqual(testList, result);
        }
Exemple #10
0
        public void AddCategory_AddsCategoryToRecipe_CategoryList()
        {
            Recipe testRecipe = new Recipe("test", 2, "test3", "test4");

            testRecipe.Save();
            Category testCategory = new Category("Mer");

            testCategory.Save();

            testRecipe.AddCategory(testCategory);

            List <Category> result   = testRecipe.GetCategories();
            List <Category> testList = new List <Category> {
                testCategory
            };

            CollectionAssert.AreEqual(testList, result);
        }
        public void Delete_DeletesRecipeAssociationsFromDatabase_RecipeList()
        {
            Category testCategory = new Category("Breakfast");

            testCategory.Save();

            Recipe testRecipe = new Recipe("cookies", "foo bar", 1);

            testRecipe.Save();
            testRecipe.AddCategory(testCategory);
            testRecipe.Delete();

            List <Recipe> resultCategoryRecipes = testCategory.GetRecipes();
            List <Recipe> testCategoryRecipes   = new List <Recipe> {
            };

            //Assert
            CollectionAssert.AreEqual(testCategoryRecipes, resultCategoryRecipes);
        }
Exemple #12
0
        public void GetCategories_ReturnsAllRecipeCategories_CategoryList()
        {
            Recipe testRecipe = new Recipe("test", 2, "test3", "test4");

            testRecipe.Save();
            Category testCategory1 = new Category("Mer");

            testCategory1.Save();
            Category testCategory2 = new Category("MerMer");

            testCategory2.Save();

            testRecipe.AddCategory(testCategory1);
            List <Category> result   = testRecipe.GetCategories();
            List <Category> testList = new List <Category> {
                testCategory1
            };

            CollectionAssert.AreEqual(testList, result);
        }
Exemple #13
0
        public void AddCategory_AddsCategoryToRecipe_CategoryList()
        {
            //Arrange
            Recipe testRecipe = new Recipe("Popplers", "Freshly laid Omikronian young", "Find fetal Omikronian, consume", 3);

            testRecipe.Save();

            Category testCategory = new Category("Future Foods");

            testCategory.Save();

            //Act
            testRecipe.AddCategory(testCategory);

            List <Category> result   = testRecipe.GetCategories();
            List <Category> testList = new List <Category> {
                testCategory
            };

            //Assert
            CollectionAssert.AreEqual(testList, result);
        }
Exemple #14
0
        public void Delete_DeletesRecipeAssociationsFromDatabase_RecipeList()
        {
            //Arrange
            Category testCategory = new Category("Home stuff");

            testCategory.Save();

            Recipe testRecipe = new Recipe("Popplers", "Freshly laid Omikronian young", "Find fetal Omikronian, consume", 3);

            testRecipe.Save();

            //Act
            testRecipe.AddCategory(testCategory);
            testRecipe.Delete();

            List <Recipe> resultCategoryRecipes = testCategory.GetRecipes();
            List <Recipe> testCategoryRecipes   = new List <Recipe> {
            };

            //Assert
            CollectionAssert.AreEqual(testCategoryRecipes, resultCategoryRecipes);
        }
Exemple #15
0
        public ActionResult Create(string newName, string ingredients, string newInstructions, int newRating, int categorySelect)
        {
            Recipe newRecipe = new Recipe(newName, newInstructions, newRating);

            newRecipe.Save();
            Category addCategory = Category.Find(categorySelect);

            newRecipe.AddCategory(addCategory);
            ingredients = ingredients.Trim();
            string [] ingredientsArray = ingredients.Split(',');
            foreach (string ingredient in ingredientsArray)
            {
                string     trimmedIngredient = ingredient.Trim();
                Ingredient foundIngredient   = Ingredient.Find(trimmedIngredient);
                if (foundIngredient == null)
                {
                    foundIngredient = new Ingredient(trimmedIngredient.ToLower());
                    foundIngredient.Save();
                }
                foundIngredient.AddRecipe(newRecipe.Id);
            }
            return(RedirectToAction("Index"));
        }