Esempio n. 1
0
        public void AddRecipeFromManagerTest()
        {
            var testRecipeDto   = RecipeModel.ModelToDto(recipe);
            var foundTestRecipe = new Recipe();

            Ingredient[]  ingArray = new Ingredient[testRecipeDto.Ingredient.Count];
            Instruction[] insArray = new Instruction[testRecipeDto.Instruction.Count];
            testRecipeDto.Ingredient.CopyTo(ingArray, 0);
            testRecipeDto.Instruction.CopyTo(insArray, 0);


            int recipeID = recipeManager.Add(testRecipeDto);

            foundTestRecipe = recipeManager.Find(recipeID);
            Ingredient[]  foundIngArray = new Ingredient[foundTestRecipe.Ingredient.Count];
            Instruction[] foundInsArray = new Instruction[foundTestRecipe.Instruction.Count];
            foundTestRecipe.Ingredient.CopyTo(foundIngArray, 0);
            foundTestRecipe.Instruction.CopyTo(foundInsArray, 0);

            Assert.IsInstanceOf(typeof(Recipe), testRecipeDto);
            Assert.IsInstanceOf(typeof(Recipe), foundTestRecipe);
            Assert.AreEqual(testRecipeDto.RecipeID, foundTestRecipe.RecipeID);
            Assert.AreEqual(testRecipeDto.Name, foundTestRecipe.Name.ToString().Trim());
            Assert.AreEqual(testRecipeDto.GlutenFree, foundTestRecipe.GlutenFree);
            Assert.AreEqual(testRecipeDto.Vegan, foundTestRecipe.Vegan);
            Assert.AreEqual(testRecipeDto.Vegetarian, foundTestRecipe.Vegetarian);
            Assert.AreEqual(testRecipeDto.Nuts, foundTestRecipe.Nuts);
            Assert.AreEqual(testRecipeDto.DairyFree, foundTestRecipe.DairyFree);


            for (int i = 0; i < ingArray.Length; i++)
            {
                Assert.AreEqual(ingArray[i].Value, foundIngArray[i].Value);
            }

            for (int i = 0; i < insArray.Length; i++)
            {
                Assert.AreEqual(insArray[i].Value, foundInsArray[i].Value);
            }

            recipeManager.RollBack(testRecipeDto);
        }
Esempio n. 2
0
        public void canAddItemsUpToFull()
        {
            // Three recipes will fitt, but not four.
            Recipe r = new Recipe(0);

            Assert.IsTrue(rm.Add(r));
            Assert.IsTrue(rm.Add(r));
            Assert.IsTrue(rm.Add(r));
            Assert.IsFalse(rm.Add(r));
        }