Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add nested collection support #11

Open
pdevito3 opened this issue Jul 24, 2023 · 0 comments
Open

Add nested collection support #11

pdevito3 opened this issue Jul 24, 2023 · 0 comments

Comments

@pdevito3
Copy link
Owner

ex:

    [Fact]
    public async Task can_filter_by_string_for_nested_collection()
    {
        // Arrange
        var testingServiceScope = new TestingServiceScope();
        var faker = new Faker();
        var fakePreparationOne = new IngredientPreparation()
        {
            Text = faker.Lorem.Sentence()
        };
        var fakeIngredientOne = new FakeIngredientBuilder()
            .Build();
        fakeIngredientOne.AddPreparation(fakePreparationOne);
        var fakeRecipeOne = new FakeRecipeBuilder().Build();
        fakeRecipeOne.AddIngredient(fakeIngredientOne);
        
        var fakeIngredientTwo = new FakeIngredientBuilder()
            .WithName(faker.Lorem.Sentence())
            .Build();
        var fakeRecipeTwo = new FakeRecipeBuilder().Build();
        fakeRecipeTwo.AddIngredient(fakeIngredientTwo);
        await testingServiceScope.InsertAsync(fakeRecipeOne, fakeRecipeTwo);
        
        var input = $"""Ingredients.Preparations.Text == "{fakePreparationOne.Text}" """;

        // Act
        var queryableRecipes = testingServiceScope.DbContext().Recipes;
        var appliedQueryable = queryableRecipes.ApplyQueryKitFilter(input);
        // var appliedQueryable = queryableRecipes.Where(x => x.Ingredients.SelectMany(y => y.Preparations).Select(y => y.Text).Any(z => (z == fakePreparationOne.Text)));
        var recipes = await appliedQueryable.ToListAsync();

        // Assert
        recipes.Count.Should().Be(1);
        recipes[0].Id.Should().Be(fakeRecipeOne.Id);
    }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant