public async Task PostRecipeWithIngredients() { var controller = CreateRecipesController(); var newIngredient = new CreatedIngredientDto("ui", 2, "unit"); var newIngredient2 = new CreatedIngredientDto("knoflook", 3, "unit"); var ingredientList = new[] { newIngredient, newIngredient2 }; var newRecipe = new CreatedRecipeDto("Test recipe", "Test description", ingredientList); var createdRecipe = await controller.PostRecipe(newRecipe); Assert.Equal("Test recipe", createdRecipe.Value.Name); Assert.Equal("Test description", createdRecipe.Value.Description); Assert.Equal(2, createdRecipe.Value.Ingredients.Count); }
public async Task PostRecipeWithIngredient() { var controller = CreateRecipesController(); var newIngredient = new CreatedIngredientDto("ui", 2, "unit"); var ingredientList = new[] { newIngredient }; var newRecipe = new CreatedRecipeDto("Test recipe", "Test description", ingredientList); var createdRecipe = await controller.PostRecipe(newRecipe); Assert.Equal("Test recipe", createdRecipe.Value.Name); Assert.Equal("Test description", createdRecipe.Value.Description); var firstIngredient = createdRecipe.Value.Ingredients.ToList()[0]; Assert.Equal("ui", firstIngredient.Name); Assert.Equal(2, firstIngredient.Amount); Assert.Equal("unit", firstIngredient.Unit); }
public Ingredient mapIngredientToDomain(CreatedIngredientDto newIngredient) { return(new Ingredient(newIngredient.Name, newIngredient.Amount, newIngredient.Unit)); }