public void AddRecipe_AddsRecipeToIngredient_RecipeList() { //Arrange Ingredient testIngredient1 = new Ingredient("Olive Oil"); testIngredient1.Save(); Recipe firstRecipe = new Recipe("Roasted Artichokes", "5", "cook"); firstRecipe.Save(); Recipe secondRecipe = new Recipe("Spaghetti", "3", "boil"); secondRecipe.Save(); List <Recipe> testList = new List <Recipe> { firstRecipe, secondRecipe }; //Act testIngredient1.AddRecipe(firstRecipe); testIngredient1.AddRecipe(secondRecipe); List <Recipe> result = testIngredient1.GetRecipes(); //Assert Assert.AreEqual(testList.Count, result.Count); }
public void GetRecipes_ReturnsAllIngredientRecipes_RecipeList() { //Arrange Ingredient testIngredient1 = new Ingredient("Artichoke"); testIngredient1.Save(); Recipe testRecipe1 = new Recipe("Roasted Artichokes", "5", "cook"); testRecipe1.Save(); Recipe testRecipe2 = new Recipe("Spaghetti", "3", "boil"); testRecipe2.Save(); //Act testIngredient1.AddRecipe(testRecipe1); List <Recipe> result = testIngredient1.GetRecipes(); List <Recipe> testList = new List <Recipe> { testRecipe1 }; //Assert Assert.AreEqual(testList.Count, result.Count); // CollectionAssert.AreEqual(testList, result); }
public ActionResult AddRecipe(int ingredientId) { Ingredient ingredient = Ingredient.Find(ingredientId); Recipe newRecipe = Recipe.Find(Int32.Parse(Request.Form["ingredient-id"])); ingredient.AddRecipe(newRecipe); return(RedirectToAction("Details", new { id = ingredientId })); }
public void AddRecipe_AddRecipeExactly() { //Arrange Ingredient newIngredient1 = new Ingredient("Egg"); newIngredient1.Save(); Recipe newRecipe = new Recipe("Scrambled Eggs", "1. Foo \n2. Bar", 8); newRecipe.Save(); List <Recipe> expectedRecipes = new List <Recipe> { newRecipe }; //Act newIngredient1.AddRecipe(newRecipe.Id); List <Recipe> recipes = newIngredient1.GetRecipes(); //Assert CollectionAssert.AreEqual(expectedRecipes, recipes); }