public void TestAddingSameIngredientsToUniqueList() { Recipe recipe = new Recipe(); Ingredients ing1 = new Ingredients(new MVC_CookBook_PSSC.Models.CommonComponents.Text("txt"), new Quantity(new MVC_CookBook_PSSC.Models.CommonComponents.Number(10), new MeasuringUnit(new MVC_CookBook_PSSC.Models.CommonComponents.ShortText("txt")))); Ingredients ing2 = new Ingredients(new MVC_CookBook_PSSC.Models.CommonComponents.Text("txt"), new Quantity(new MVC_CookBook_PSSC.Models.CommonComponents.Number(10), new MeasuringUnit(new MVC_CookBook_PSSC.Models.CommonComponents.ShortText("txt")))); Ingredients ing3 = new Ingredients(new MVC_CookBook_PSSC.Models.CommonComponents.Text("txt2"), new Quantity(new MVC_CookBook_PSSC.Models.CommonComponents.Number(10), new MeasuringUnit(new MVC_CookBook_PSSC.Models.CommonComponents.ShortText("txt")))); recipe.AddInexistentIngredient(ing1); recipe.AddInexistentIngredient(ing2); Assert.AreNotSame(ing1, ing2); Assert.AreEqual(1, recipe.GetIngredients.Count); recipe.AddInexistentIngredient(ing3); Assert.AreNotSame(ing1, ing3); Assert.AreEqual(2, recipe.GetIngredients.Count); }
public void TestRemoveIngredientThrow() { Recipe recipe = new Recipe(); Ingredients ing1 = new Ingredients(new MVC_CookBook_PSSC.Models.CommonComponents.Text("txt"), new Quantity(new MVC_CookBook_PSSC.Models.CommonComponents.Number(10), new MeasuringUnit(new MVC_CookBook_PSSC.Models.CommonComponents.ShortText("txt")))); Ingredients ing2 = new Ingredients(new MVC_CookBook_PSSC.Models.CommonComponents.Text("txt3"), new Quantity(new MVC_CookBook_PSSC.Models.CommonComponents.Number(10), new MeasuringUnit(new MVC_CookBook_PSSC.Models.CommonComponents.ShortText("txt")))); recipe.AddInexistentIngredient(ing1); Assert.AreEqual(1, recipe.GetIngredients.Count); Assert.Throws <InexistentIngredientException>(() => recipe.RemoveIngredient(ing2)); }
public void GetIngredientsWithInexistentIngredient() { Recipe recipe = new Recipe(); Ingredients ing1 = new Ingredients(new MVC_CookBook_PSSC.Models.CommonComponents.Text("txt"), new Quantity(new MVC_CookBook_PSSC.Models.CommonComponents.Number(10), new MeasuringUnit(new MVC_CookBook_PSSC.Models.CommonComponents.ShortText("txt")))); recipe.AddInexistentIngredient(ing1); var returned = recipe.GetSpecificIngredient(new MVC_CookBook_PSSC.Models.CommonComponents.Text("nope")); Assert.IsNull(returned); }