diff --git a/MCTG/ConsoleApp/Program.cs b/MCTG/ConsoleApp/Program.cs index ac9a1e9..2ee01cb 100644 --- a/MCTG/ConsoleApp/Program.cs +++ b/MCTG/ConsoleApp/Program.cs @@ -13,17 +13,13 @@ Console.WriteLine("Hello, World!\n\n"); Stub stub = new Stub(); -List recipes = stub.LoadRecipes(); -List recipeCollections = stub.LoadRecipeCollection(); - -RecipeCollection? allRecipe = recipeCollections.Find(x => x.Description.Equals("All")); -if (allRecipe == null) - throw new ArgumentException("Load AllRecipe in stub: can't find 'All'."); - -Manager manager = new Manager(allRecipe); - -Recipe? ret = SearcherRecipe.ResearchOn(allRecipe); -Console.WriteLine(ret); +List users = stub.ConstrucList(); +RecipeCollection recipes = new RecipeCollection("all", stub.LoadRecipes().ToArray()); + +Console.WriteLine(recipes); +Console.WriteLine("\n---------------------------\n"); + +recipes[] // press any key to quit Console.ReadKey(); diff --git a/MCTG/ConsoleApp/Stubs/Stub.cs b/MCTG/ConsoleApp/Stubs/Stub.cs index f116321..8ec1b68 100644 --- a/MCTG/ConsoleApp/Stubs/Stub.cs +++ b/MCTG/ConsoleApp/Stubs/Stub.cs @@ -15,24 +15,24 @@ namespace ConsoleApp List stub = new List(); stub.AddRange(new[] { - new Recipe(), + new Recipe(""), new Recipe( title: "Cookies"), new Recipe( - title: "Cookies", id: 23), + title: "Cookies"), new Recipe( - title: "Cookies au chocolat", id: null), + title: "Cookies au chocolat"), new Recipe( - title: "", id: null), + title: ""), new Recipe( - title: "", id: 24), + title: ""), new Recipe( - title: "Cookies", id: 24, + title: "Cookies", preparationSteps: new[]{ new PreparationStep(1) }), new Recipe( - title: "Cookies", id: 26, + title: "Cookies", preparationSteps: new[]{ new PreparationStep(1), new PreparationStep(2, "Faire cuire.") diff --git a/MCTG/Tests/Model_UnitTests/RecipeCollection_UT.cs b/MCTG/Tests/Model_UnitTests/RecipeCollection_UT.cs index 36008b1..b79b884 100644 --- a/MCTG/Tests/Model_UnitTests/RecipeCollection_UT.cs +++ b/MCTG/Tests/Model_UnitTests/RecipeCollection_UT.cs @@ -17,12 +17,14 @@ namespace Model_UnitTests description: "test recipe", recipes: new[] { - new Recipe(title: "Gateau à la crème", id: 1), - new Recipe(title: "Gateau au chocolat", id: 2), - new Recipe(title: "Gateau aux cerises", id: 3) + new Recipe(title: "Gateau à la crème"), + new Recipe(title: "Gateau au chocolat"), + new Recipe(title: "Gateau aux cerises") }); - Assert.Equal(2, recipes.ResearchByName("chocolat").FirstOrDefault().Id); + Recipe? search_result = recipes.ResearchByName("chocolat").FirstOrDefault(); + Assert.NotNull(search_result); + Assert.Equal("Gateau au chocolat", search_result.Title); } } } diff --git a/MCTG/Tests/Model_UnitTests/Recipe_UT.cs b/MCTG/Tests/Model_UnitTests/Recipe_UT.cs index 9655041..4fdce86 100644 --- a/MCTG/Tests/Model_UnitTests/Recipe_UT.cs +++ b/MCTG/Tests/Model_UnitTests/Recipe_UT.cs @@ -7,22 +7,8 @@ namespace Model_UnitTests [Fact] public void TestVoidConstructor() { - Recipe r = new Recipe(id: 999); // id is given to avoid tests errors with the static atrribute 'idCreator'. + Recipe r = new Recipe(""); // id is given to avoid tests errors with the static atrribute 'idCreator'. Assert.NotNull(r.Title); } - - [Theory] - [InlineData("Cookies", 23, "Cookies", 23)] - [InlineData("Cookies", 1, "Cookies", 1)] - [InlineData("No title.", 1, "", 1)] - public void TestConstructor(string expectedTitle, int expectedId, string title, int? id) - { - Recipe r = new Recipe(title, id); - Assert.NotNull(r.Title); - Assert.Equal(expectedId, r.Id); - Assert.Equal(expectedTitle, r.Title); - } - - } }