예제 #1
0
    public void GetIngredients()
    {
        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);
        var ingredient = inMemoryDbContext.Ingredients.Add(new Ingredient(tomato, 2, piece));

        inMemoryDbContext.SaveChanges();
        var testee = new IngredientDbAccess(inMemoryDbContext);

        var result = testee.GetIngredients();

        result.Should().Contain(ingredient.Entity);
    }
예제 #2
0
    /// <inheritdoc />
    public IEnumerable <ExistingIngredientDto> GetAllIngredients()
    {
        var ingredients = IngredientDbAccess.GetIngredients();

        return(Mapper.Map <IEnumerable <ExistingIngredientDto> >(ingredients));
    }