示例#1
0
        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);
        }
示例#2
0
        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));
        }
示例#3
0
        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);
        }