/// <inheritdoc /> public ExistingIngredientDto CreateIngredient(NewIngredientDto newIngredientDto) { var newIngredient = Mapper.Map <Ingredient>(newIngredientDto); var createdIngredient = IngredientDbAccess.AddIngredient(newIngredient); return(Mapper.Map <ExistingIngredientDto>(createdIngredient)); }
public void CreateIngredient() { using var inMemoryDbContext = new InMemoryDbContext(); var vegetables = new ArticleGroup("Vegetables"); var tomato = new Article { Name = "Tomato", ArticleGroup = vegetables, IsInventory = false }; var piece = new Unit("Piece"); inMemoryDbContext.ArticleGroups.Add(vegetables); inMemoryDbContext.Articles.Add(tomato); inMemoryDbContext.Units.Add(piece); inMemoryDbContext.SaveChanges(); var testee = new IngredientDbAccess(inMemoryDbContext); var result = testee.AddIngredient(new Ingredient(tomato, 2, piece)); inMemoryDbContext.SaveChanges(); inMemoryDbContext.Ingredients.Should().Contain(result); }