public async Task GetRecipesAsync_Success(IEnumerable <Recipe> recipes) { A.CallTo(() => recipeService.GetRecipesAsync()).Returns(recipes); var result = await sut.GetRecipesAsync().ConfigureAwait(false); result.Should().BeEquivalentTo(recipes); }
public async Task GetRecipe_IfIsItems_ReturnItems() { // Arrange MakeMockGetWithIncludeListForRepository(); // Act // Run method which should be tested var listRecipes = await _controller.GetRecipesAsync(); // Assert Assert.Same(_expectedListRecipe, listRecipes); _repositoryMock.VerifyAll(); }
public static async Task FindRecipeAsync(RecipeController recipeController, IngredientController ingredientController, string answer = "") { foreach (var recipes in await recipeController.GetRecipesAsync()) { Console.WriteLine($"{recipes.Id}. {recipes.Name}."); } Console.Write("Введите id рецeпта : "); answer = Console.ReadLine(); if (answer.ToLower() == "bye" || answer.ToLower() == "back") { return; } if (!int.TryParse(answer, out int recipeId)) { return; } recipeController.CurrentRecipe = await recipeController.FindRecipeAsync(recipeId); if (!string.IsNullOrWhiteSpace(recipeController.CurrentRecipe.Name)) { await OpenCurrentRecipeAsync(recipeController, ingredientController); } }
public static async Task BookRecipes(CategoryController categoryController, RecipeController recipeController, IngredientController ingredientController, string answer = "") { while (true) { Console.Clear(); Console.WriteLine("\t\t*exit: bye, back: back, open recipe: {id}*"); DisplayCategoryTree(await categoryController.GetCategoriesAsync(), await recipeController.GetRecipesAsync(), true); Console.WriteLine("Что бы открыть рецепт введите {id}:"); answer = Console.ReadLine().ToLower(); if (IsExit(answer)) { break; } if (int.TryParse(answer, out int recipeId)) { recipeController.CurrentRecipe = await recipeController.FindRecipeAsync(recipeId); await OpenCurrentRecipeAsync(recipeController, ingredientController); } else { Console.WriteLine("Некорректно веден формат: \"x (где x - целое число).\""); Console.WriteLine("\t\t**enter**"); Console.ReadLine(); } } }