Exemplo n.º 1
0
        public async Task GetRecipeSuccess(DBModel.Recipe recipe, IEnumerable <DBModel.GetRecipeIngredient> ingredients)
        {
            A.CallTo(() => recipeRepository.GetRecipeAsync(recipe.Id)).Returns(recipe);
            A.CallTo(() => recipeRepository.GetRecipeIngredientsAsync(recipe.Id)).Returns(ingredients);

            var expected = ingredients.Select(x => new RecipeIngredient
            {
                Amount = x.Amount,
                Name   = x.IngredientName,
                Unit   = x.UnitName
            });

            var result = await sut.GetRecipeAsync(recipe.Id).ConfigureAwait(false);

            result.Name.Should().Be(recipe.Name);
            result.Id.Should().Be(recipe.Id);
            result.Ingredients.Should().BeEquivalentTo(expected);
        }
Exemplo n.º 2
0
        public async Task CreateRecipeSuccess(DBModel.Recipe recipe, IEnumerable <DBModel.RecipeIngredient> ingredients)
        {
            A.CallTo(() => recipeRepository.CreateRecipeAsync(recipe.Name, transaction)).Returns(recipe.Id);

            var newRecipe = new NewRecipe
            {
                Name        = recipe.Name,
                Ingredients = ingredients.Select(x => new RecipeIngredient
                {
                    Amount = x.Amount,
                    Name   = x.IngredientName,
                    Unit   = x.UnitName
                }).ToList()
            };

            await sut.CreateRecipeAsync(newRecipe).ConfigureAwait(false);

            A.CallTo(() => recipeRepository.CreateRecipeAsync(recipe.Name, transaction)).MustHaveHappenedOnceExactly();
            A.CallTo(() => recipeRepository.UpsertRecipeIngredientsAsync(recipe.Id, A <IEnumerable <DBModel.RecipeIngredient> > ._, transaction)).MustHaveHappenedOnceExactly();
        }