public async Task AddedIfNew_IfExist_ReturnItem() { //Arrange MakeMockGetWithIncludeEntityForRepository(); // Act // Run method which should be tested var entityId = await _controller.AddedIfNewAsync("expected"); // Assert _repositoryMock.VerifyAll(); Assert.Equal(_expectedIngredient.Id, entityId); }
public static async Task FindIngredientAsync(IngredientController ingredientController, string answer = "") { Console.Write("Введите название ингредиента : "); var ingr = await ingredientController.FindAndGetIngredientAsync(Console.ReadLine().ToLower()); if (ingr != null) { Console.WriteLine($"{ingr.Name} есть в списке."); Console.ReadLine(); } else { Console.WriteLine(); while (true) { Console.Write( "Такого ингредиента нет, создать ли ?\n" + "1. да\n" + "2. нет\n" + "(number): "); if (int.TryParse(Console.ReadLine(), out int tempResult)) { int countIngredients = 0; switch (tempResult) { case 1: do { Console.WriteLine("Введите колличество ингредиентов: "); answer = Console.ReadLine(); } while (!int.TryParse(answer, out countIngredients)); var ingredientsId = new List <int>(); for (int count = 1; count <= countIngredients; count++) { Console.WriteLine("Введите ингредиент:"); Console.Write($"{count}. "); ingredientsId.Add(await ingredientController.AddedIfNewAsync(Console.ReadLine())); } return; case 2: return; } } } } }
public static async Task AddIngredientsAsync(IngredientController ingredientController, string answer = "", int count = 0) { do { Console.WriteLine("Введите колличество ингредиентов: "); answer = Console.ReadLine(); } while (!int.TryParse(answer, out count)); var ingredientsId = new List <int>(); for (int i = 1; i <= count; i++) { Console.WriteLine("Введите ингредиент:"); Console.Write($"{i}. "); ingredientsId.Add(await ingredientController.AddedIfNewAsync(Console.ReadLine())); } }
public static async Task AddRecipeAsync(CategoryController categoryController, RecipeController recipeController, IngredientController ingredientController, string answer = "", int count = 0) { Console.WriteLine("Введите название рецепта: "); var name = Console.ReadLine(); DisplayCategoryTree(await categoryController.GetCategoriesAsync(), null, false); Console.Write("Ввидите категорию блюда (id) : "); await categoryController.WalkCategoriesAsync(Console.ReadLine()); var categoryNew = categoryController.CurrentCategory; if (categoryNew == null) { throw new ArgumentException(nameof(categoryNew), "Null categoryNew in new Recipe"); } Console.Clear(); Console.WriteLine("Введите описание блюда: "); var description = Console.ReadLine(); Console.Clear(); do { Console.WriteLine("Введите колличество ингредиентов: "); answer = Console.ReadLine(); } while (!int.TryParse(answer, out count)); var ingredientsId = new List <int>(); for (int i = 1; i <= count; i++) { Console.WriteLine("Введите ингредиент:"); Console.Write($"{i}. "); ingredientsId.Add(await ingredientController.AddedIfNewAsync(Console.ReadLine())); } Console.WriteLine("\t\t*enter*"); Console.ReadKey(); Console.Clear(); List <string> countIngred = new List <string>(); var tempIngredients = await ingredientController.GetIngredientsAsync(); for (int id = 0; id < ingredientsId.Count; id++) { Console.WriteLine("Введите колличество для " + $"\"{tempIngredients.First(i => i.Id == ingredientsId[id]).Name}\": "); countIngred.Add(Console.ReadLine()); } int countSteps = 0; do { Console.WriteLine(); Console.Clear(); Console.Write("Введите колличество шагов приготовления: "); answer = Console.ReadLine(); } while(!int.TryParse(answer, out countSteps)); List <string> stepsHowCooking = new List <string>(); Console.WriteLine(); for (int i = 1; i <= countSteps; i++) { Console.WriteLine($"Введите описания шага {i} : "); answer = Console.ReadLine(); stepsHowCooking.Add(answer); } await recipeController.CreateRecipeAsync(name, categoryNew.Id, description); await recipeController.AddedIngredientsInRecipeAsync(ingredientsId, countIngred); await recipeController.AddedStepsInRecipeAsync(stepsHowCooking); }