Ejemplo n.º 1
0
 public static Ingredient ToDomain(this IngredientTO IngredientTO)
 {
     return(new Ingredient(IngredientTO.Name, IngredientTO.IsAllergen)
     {
         Id = IngredientTO.Id
     });
 }
        public void MyTestMethod()
        {
            var options = new DbContextOptionsBuilder <MealContext>()
                          .UseInMemoryDatabase(databaseName: MethodBase.GetCurrentMethod().Name)
                          .Options;

            using (var memoryCtx = new MealContext(options))
            {
                //ARRANGE
                var IngredientToUseInTest = new IngredientTO
                {
                    Id         = 1,
                    IsAllergen = true,
                    Name       = new MultiLanguageString("Ingr1EN", "Ingr1FR", "Ingr1NL")
                };

                IRepositoryDO_NOT_USE <IngredientTO, int> ingredientRepository2 = new IngredientRepository2(memoryCtx);

                //ACT
                ingredientRepository2.Create(IngredientToUseInTest);
                memoryCtx.SaveChanges();
                //MealToUseInTest.Id = 1;
                IngredientToUseInTest.IsAllergen = false;
                ingredientRepository2.Edit(IngredientToUseInTest);
                var qtdEntriesToAssert = memoryCtx.SaveChanges();

                var IngredientToAssert = ingredientRepository2.GetById(1);
                //ASSERT
                Assert.AreEqual(1, qtdEntriesToAssert);
                Assert.AreEqual(1, ingredientRepository2.GetAll().Count());
                Assert.AreEqual(1, IngredientToAssert.Id);
                Assert.IsFalse(IngredientToAssert.IsAllergen);
                Assert.AreEqual("Ingr1EN", IngredientToAssert.Name.English);
            }
        }
Ejemplo n.º 3
0
        public static IngredientEF ToEF(this IngredientTO ingredientTO)
        {
            if (ingredientTO is null)
            {
                throw new ArgumentNullException(nameof(ingredientTO));
            }

            return(new IngredientEF
            {
                Id = ingredientTO.Id,
                NameEnglish = ingredientTO.Name.English,
                NameFrench = ingredientTO.Name.French,
                NameDutch = ingredientTO.Name.Dutch,
                IsAllergen = ingredientTO.IsAllergen
            });
        }
Ejemplo n.º 4
0
        public static IngredientEF ToEF(this IngredientTO Ingredient)
        {
            if (Ingredient is null)
            {
                throw new ArgumentNullException(nameof(Ingredient));
            }

            return(new IngredientEF()
            {
                Id = Ingredient.Id,
                NameEnglish = Ingredient.Name.English,
                NameFrench = Ingredient.Name.French,
                NameDutch = Ingredient.Name.Dutch,

                IsAllergen = Ingredient.IsAllergen
            });
        }
Ejemplo n.º 5
0
        public static Ingredient ToDomain(this IngredientTO ingredientTO)
        {
            if (ingredientTO is null)
            {
                throw new ArgumentNullException(nameof(ingredientTO));
            }

            var ingredient = new Ingredient
            {
                Id         = ingredientTO.Id,
                Name       = ingredientTO.Name,
                IsAllergen = ingredientTO.IsAllergen
            };

            ingredient.CheckValidity();

            return(ingredient);
        }
Ejemplo n.º 6
0
        public static List <MealTO> GetTestsListOfMeals()
        {
            //REchercher Founisseur
            var Tomate = new IngredientTO {
                Id = 1, Name = new MultiLanguageString("Tomato", "Tomate", "Tomaat"), IsAllergen = false
            };
            var Brie = new IngredientTO {
                Id = 2, Name = new MultiLanguageString("Brie", "Brie", "Brie"), IsAllergen = true
            };
            var Fromage = new IngredientTO {
                Id = 3, Name = new MultiLanguageString("Cheese", "Fromage", "Kaas"), IsAllergen = true
            };
            var Noix = new IngredientTO {
                Id = 4, Name = new MultiLanguageString("Nuts", "Noix", "Noten"), IsAllergen = true
            };
            var Beurre = new IngredientTO {
                Id = 5, Name = new MultiLanguageString("Butter", "Beurre", "Boter"), IsAllergen = false
            };
            var Jambon = new IngredientTO {
                Id = 6, Name = new MultiLanguageString("Ham", "Jambon", "Ham"), IsAllergen = false
            };
            var Roquette = new IngredientTO {
                Id = 7, Name = new MultiLanguageString("Arugula", "Roquette", "Rucola"), IsAllergen = false
            };
            var Salade = new IngredientTO {
                Id = 8, Name = new MultiLanguageString("Salad", "Salade", "Salade"), IsAllergen = false
            };
            var Pesto = new IngredientTO {
                Id = 9, Name = new MultiLanguageString("Pesto", "Pesto", "Pesto"), IsAllergen = false
            };
            var Oeuf = new IngredientTO {
                Id = 10, Name = new MultiLanguageString("Eggs", "Oeufs", "Eien"), IsAllergen = true
            };
            var Miel = new IngredientTO {
                Id = 11, Name = new MultiLanguageString("Honey", "Miel", "Honing"), IsAllergen = false
            };

            MealTO Club = new MealTO {
                Id = 1, Name = new MultiLanguageString("ClubEN", "ClubFR", "ClubNL"), Supplier = new SupplierTO {
                    Id = 33, Name = "Supplier1"
                }, Ingredients = new List <IngredientTO>(), MealType = MealType.Sandwich
            };
            MealTO BrieNoix = new MealTO {
                Id = 2, Name = new MultiLanguageString("BrieEN", "BrieFR", "BrieNL"), Supplier = new SupplierTO {
                    Id = 33, Name = "Supplier1"
                }, Ingredients = new List <IngredientTO>(), MealType = MealType.Sandwich
            };
            MealTO PestoVerde = new MealTO {
                Id = 3, Name = new MultiLanguageString("PestoEN", "PestoFR", "PestoNL"), Supplier = new SupplierTO {
                    Id = 33, Name = "Supplier1"
                }, Ingredients = new List <IngredientTO>(), MealType = MealType.Sandwich
            };

            BrieNoix.Ingredients.Add(Brie);
            BrieNoix.Ingredients.Add(Miel);
            BrieNoix.Ingredients.Add(Noix);

            PestoVerde.Ingredients.Add(Pesto);
            PestoVerde.Ingredients.Add(Roquette);
            PestoVerde.Ingredients.Add(Oeuf);

            Club.Ingredients.Add(Jambon);
            Club.Ingredients.Add(Beurre);
            Club.Ingredients.Add(Salade);
            Club.Ingredients.Add(Fromage);
            //Rechercher la liste de meal

            var lst = new List <MealTO>();;

            lst.Add(BrieNoix);
            lst.Add(Club);
            lst.Add(PestoVerde);

            return(lst);
        }