public void Setup() { //setup the connections and context SetupConnectionAndContext(); //create the repository for cooking instructions cookingInstructionRepository = new CookingInstructionRepository(Context); }
public void GetCookingInstructions_RecipeFound_ReturnsInstructions() { //create the new recipe var recipe = new Recipe() { Name = "Butter Chicken" }; //find the added recipe 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" } }; //add the instructions var instructionsRepository = new CookingInstructionRepository(Context); instructionsRepository.AddRange(instructions); //get all instructions and now add it to the recipe var instructionList = instructionsRepository.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 = instructionsRepository.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()); } }
/// <summary> /// Default Constructor /// </summary> public CookingInstruction() : base() { cookingInstructionRepository = new CookingInstructionRepository(RecipeContext); }