Exemple #1
0
            public IngrediantTestData()
            {
                Recipes = new List <Recipe>()
                {
                    new Recipe()
                    {
                        Name = "Test Recipe 1", Id = 1, Calories = 1, CookedCounter = 0, LastTimeCooked = new DateTime(), NumberOfServings = 1, SourceId = 1, Creator = "Tester"
                    },
                    new Recipe()
                    {
                        Name = "Test Recipe 2", Id = 2, Calories = 1, CookedCounter = 0, LastTimeCooked = new DateTime(), NumberOfServings = 1, SourceId = 2, Creator = "Tester"
                    },
                    new Recipe()
                    {
                        Name = "Test Recipe 3", Id = 3, Calories = 1, CookedCounter = 0, LastTimeCooked = new DateTime(), NumberOfServings = 1, SourceId = 3, Creator = "Tester"
                    }
                };

                Ingrediants = new List <Ingrediant>()
                {
                    new Ingrediant()
                    {
                        Id = 1, Name = "Test Ingrediant 1"
                    },
                    new Ingrediant()
                    {
                        Id = 2, Name = "Test Ingrediant 2"
                    },
                    new Ingrediant()
                    {
                        Id = 3, Name = "Test Ingrediant 3"
                    },
                };

                var firstRecipe        = Recipes.First();
                var recipe1Ingrediant1 = new RecipeIngrediant()
                {
                    Amount = 1, CookingUnit = CookingUnit.Gramm, Recipe = firstRecipe, RecipeId = firstRecipe.Id, Ingrediant = Ingrediants.First(), IngrediantId = Ingrediants.First().Id
                };
                var recipe1Ingrediant2 = new RecipeIngrediant()
                {
                    Amount = 1, CookingUnit = CookingUnit.Gramm, Recipe = firstRecipe, RecipeId = firstRecipe.Id, Ingrediant = Ingrediants[1], IngrediantId = Ingrediants[1].Id
                };
                var recipe1Ingrediant3 = new RecipeIngrediant()
                {
                    Amount = 1, CookingUnit = CookingUnit.Gramm, Recipe = firstRecipe, RecipeId = firstRecipe.Id, Ingrediant = Ingrediants.Last(), IngrediantId = Ingrediants.Last().Id
                };

                firstRecipe.Ingrediants.Add(recipe1Ingrediant1);
                firstRecipe.Ingrediants.Add(recipe1Ingrediant2);
                firstRecipe.Ingrediants.Add(recipe1Ingrediant3);

                Ingrediants[0].Recipes.Add(recipe1Ingrediant1);
                Ingrediants[1].Recipes.Add(recipe1Ingrediant2);
                Ingrediants[2].Recipes.Add(recipe1Ingrediant3);
            }
Exemple #2
0
            public RecipeTestData()
            {
                #region Init Recipe

                // ------------------- Generel ----------------------
                Recipe = new Recipe()
                {
                    Name             = "My Recipe",
                    Id               = 1,
                    Calories         = 1,
                    CookedCounter    = 2,
                    Creator          = "Tester",
                    LastTimeCooked   = new DateTime(),
                    NumberOfServings = 3
                };

                // ------------------- Images ----------------------
                var image = new RecipeImage()
                {
                    Recipe   = this.Recipe,
                    Id       = 1,
                    RecipeId = Recipe.Id,
                    Url      = "http://imageUrl.de",
                    Filename = "MyImage.jpg"
                };
                Recipe.Images.Add(image);

                // ------------------- Steps ----------------------

                var steps = new List <RecipeStep>()
                {
                    new RecipeStep()
                    {
                        Recipe = Recipe, Id = 1, RecipeId = Recipe.Id, Order = 0, Description = "Step 1"
                    },
                    new RecipeStep()
                    {
                        Recipe = Recipe, Id = 2, RecipeId = Recipe.Id, Order = 1, Description = "Step 2"
                    }
                };
                Recipe.Steps.AddRange(steps);

                // ------------------- Tags ----------------------

                var tags = new List <RecipeTag>()
                {
                    new RecipeTag()
                    {
                        Id = 1, Name = "Tag 1"
                    },
                    new RecipeTag()
                    {
                        Id = 2, Name = "Tag 2"
                    },
                };

                var recipeTags = new List <RecipeRecipeTag>()
                {
                    new RecipeRecipeTag()
                    {
                        Recipe = Recipe, RecipeId = Recipe.Id, RecipeTag = tags.First(), RecipeTagId = tags.First().Id
                    },
                    new RecipeRecipeTag()
                    {
                        Recipe = Recipe, RecipeId = Recipe.Id, RecipeTag = tags.Last(), RecipeTagId = tags.Last().Id
                    },
                };

                tags.First().Recipes.Add(recipeTags.First());
                tags.Last().Recipes.Add(recipeTags.Last());
                Recipe.Tags.AddRange(recipeTags);

                // ------------------- Source ----------------------

                var source = new RecipeUrlSource()
                {
                    Id   = 1,
                    Name = "WebSource",
                    Url  = "http://www.websource.de"
                };
                var recipeSource = new RecipeSourceRecipe()
                {
                    Page     = 0,
                    Recipe   = Recipe,
                    RecipeId = Recipe.Id,
                    Source   = source,
                    SourceId = source.Id
                };
                source.RecipeSourceRecipes.Add(recipeSource);
                Recipe.Source   = recipeSource;
                Recipe.SourceId = source.Id;

                // ------------------- Ingrediant ----------------------

                var ingrediant = new Ingrediant()
                {
                    Id   = 1,
                    Name = "Ingrediant 1"
                };

                var recipeIngrediant = new RecipeIngrediant()
                {
                    Recipe       = Recipe,
                    RecipeId     = Recipe.Id,
                    Ingrediant   = ingrediant,
                    IngrediantId = ingrediant.Id,
                    Amount       = 1,
                    CookingUnit  = CookingUnit.Gramm
                };
                ingrediant.Recipes.Add(recipeIngrediant);
                Recipe.Ingrediants.Add(recipeIngrediant);

                #endregion
                UpdateModel = new RecipeUpdateViewModel()
                {
                    Id               = 1,
                    Name             = "Old Recipe",
                    Url              = "http://www.webservice.de/recipes/1",
                    Calories         = Recipe.Calories.GetValueOrDefault(),
                    NumberOfServings = Recipe.NumberOfServings
                };
                CreationModel = new RecipeCreationViewModel()
                {
                    Name             = UpdateModel.Name,
                    Calories         = UpdateModel.Calories,
                    NumberOfServings = UpdateModel.NumberOfServings,
                    Creator          = Recipe.Creator
                };
            }