예제 #1
0
        public async Task FindRecipe_IfExists_ReturnRecipe()
        {
            //Arrange
            MakeMockGetWithIncludeEntityForRepository();

            // Act
            // Run method which should be tested
            var recipe = await _controller.FindRecipeAsync(1);

            // Assert
            _repositoryMock.VerifyAll();
            Assert.Equal(_expectedRecipe, recipe);
        }
예제 #2
0
        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();
                }
            }
        }
예제 #3
0
        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);
            }
        }