Beispiel #1
0
        public void AddIngredientToRecipe_BothFound_ReturnsTrue()
        {
            //create the new recipe
            var recipe = new Recipe()
            {
                Name = "Butter Chicken"
            };


            //find the added recipe
            var recipeRepository = new RecipeRepository(Context);
            var foundRecipe      = recipeRepository.Find(recipe => recipe.Name == "Butter Chicken")
                                   .FirstOrDefault();
            //create ingredients
            var ingredients = new List <Ingredient>()
            {
                new Ingredient()
                {
                    Name = "Whole Chicken"
                },
                new Ingredient()
                {
                    Name = "Sour Cream"
                },
                new Ingredient()
                {
                    Name = "Gee"
                }
            };

            //add the ingredients
            ingredientRepository.AddRange(ingredients);

            //get all ingredients and now add it to the recipe
            var ingredientsList = ingredientRepository.GetAll().ToList();

            //three ingredients should be added to the database
            Assert.AreEqual(3, ingredientsList.Count());

            //found the recipe and ingredients list
            if (foundRecipe != null && ingredientsList != null)
            {
                var addedToRecipe = false;


                foreach (var ingredient in ingredientsList)
                {
                    //add the ingredients to the recipe
                    addedToRecipe = ingredientRepository.AddIngredientToRecipe(foundRecipe.RecipeId, ingredient.IngredientId);
                    Assert.IsTrue(addedToRecipe);
                }

                //Insure that the foundRecipe has the same count as the ingredients list
                Assert.AreEqual(foundRecipe.Ingredients.Count(), ingredientsList.Count());
            }
        }
Beispiel #2
0
        public void AssignCookingInstructionsToRecipe_BothExists_ReturnsTrue()
        {
            //create the new recipe
            var recipe = new Recipe()
            {
                Name = "Butter Chicken"
            };

            //find the added recipe
            var recipeRepository = new RecipeRepository(Context);
            var foundRecipe      = recipeRepository.Find(recipe => recipe.Name == "Butter Chicken")
                                   .FirstOrDefault();
            //create instructions
            var instructions = new List <CookingInstruction>()
            {
                new CookingInstruction()
                {
                    Name = "Prepare The Chicken", Instruction = "Cut the chicken into small cubes"
                },
                new CookingInstruction()
                {
                    Name = "Creating The Curry", Instruction = "Mix all the dry ingredient together and when mussy add the chicken"
                },
                new CookingInstruction()
                {
                    Name = "Cooking Instructions", Instruction = "Cook the chicken in the curry for 20 minutes or until the chicken is done"
                }
            };

            cookingInstructionRepository.AddRange(instructions);

            //get all instructions and now add it to the recipe
            var instructionList = cookingInstructionRepository.GetAll().ToList();

            //three instructions should be added to the database
            Assert.AreEqual(3, instructionList.Count());

            //found the recipe and instructions list
            if (foundRecipe != null && instructionList != null)
            {
                var addedToRecipe = false;


                foreach (var instruction in instructionList)
                {
                    //add the instructions to the recipe
                    addedToRecipe = cookingInstructionRepository.AssignCookingInstructionsToRecipe(foundRecipe.RecipeId, instruction.CookingInstructionId);
                    Assert.IsTrue(addedToRecipe);
                }

                //Insure that the foundRecipe has the same count as the ingredients list
                Assert.AreEqual(foundRecipe.Ingredients.Count(), instructionList.Count());
            }
        }
Beispiel #3
0
        public void AddRecipe()
        {
            //create the new recipe
            var recipe = new Recipe()
            {
                Name = "Butter Chicken"
            };

            //Add to the database
            recipeRepository.Add(recipe);

            //retrieve using the find method
            var foundRecipe = recipeRepository.Find(recipe => recipe.Name == recipe.Name)
                              .FirstOrDefault();

            //found it
            if (foundRecipe != null)
            {
                Assert.AreEqual(recipe.Name, foundRecipe.Name);
            }
        }