Example #1
0
 public void Save()
 {
     Categories.Save();
     Ingredients.Save();
     RecipeIngredients.Save();
     Recipes.Save();
 }
        public ActionResult AddIngredient(int recipeId, string ingredient)
        {
            if (Ingredient.FindIngredientByName(ingredient).GetId() == 0)
            {
                Ingredient newIngredient = new Ingredient(ingredient);
                newIngredient.Save();
            }
            RecipeIngredients newPair = new RecipeIngredients(recipeId, Ingredient.FindIngredientByName(ingredient).GetId());

            newPair.Save();
            return(RedirectToAction("Detail", new { id = recipeId }));
        }
Example #3
0
        public void Find_FindRecipeIngredientsInDatabase_RecipeIngredients()
        {
            //Arrange
            RecipeIngredients testRecipeIngredients = new RecipeIngredients(1, 1);

            testRecipeIngredients.Save();

            //Act
            RecipeIngredients resultById = RecipeIngredients.FindRecipeIngredientsById(testRecipeIngredients.GetId());

            //Assert
            Assert.AreEqual(testRecipeIngredients, resultById);
        }
Example #4
0
        public void SaveAndGetAll_SavesToDatabaseAndReturnAll_RecipeIngredients()
        {
            //Arrange
            RecipeIngredients testRecipeIngredients = new RecipeIngredients(1, 1);

            //Act
            testRecipeIngredients.Save();
            List <RecipeIngredients> result   = RecipeIngredients.GetAll();
            List <RecipeIngredients> testList = new List <RecipeIngredients> {
                testRecipeIngredients
            };

            //Assert
            CollectionAssert.AreEqual(testList, result);
        }
Example #5
0
        public void Save_AssignsIdToObject_Id()
        {
            //Arrange
            RecipeIngredients testRecipeIngredients = new RecipeIngredients(1, 1);

            //Act
            testRecipeIngredients.Save();
            RecipeIngredients savedRecipeIngredients = RecipeIngredients.GetAll()[0];

            int result = savedRecipeIngredients.GetId();
            int testId = testRecipeIngredients.GetId();

            //Assert
            Assert.AreEqual(testId, result);
        }