Skip to content

Commit

Permalink
Test to verify that Include() plus ToPagedList() works after the LINQ…
Browse files Browse the repository at this point in the history
… overhaul. Closes GH-2553
  • Loading branch information
jeremydmiller committed Nov 27, 2023
1 parent 02815f7 commit 67d5b7d
Showing 1 changed file with 45 additions and 0 deletions.
45 changes: 45 additions & 0 deletions src/LinqTests/Bugs/Bug_2553_Include_with_ToPagedList.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
using System;
using System.Collections.Generic;
using System.Linq;
using Marten.Pagination;
using Marten.Testing.Harness;
using Shouldly;

namespace LinqTests.Bugs;

public class Bug_2553_Include_with_ToPagedList: BugIntegrationContext
{
public record Foo(Guid Id);

public record Bar(Guid Id, Guid FooId);

[Fact]
public void query_should_return_included_docs()
{
var foos = Enumerable.Range(start: 0, count: 100).Select(i => new Foo(Guid.NewGuid())).ToArray();
var bars = Enumerable.Range(start: 0, count: 100).Select(i => new Bar(Guid.NewGuid(), FooId: foos[i].Id));

foreach (var foo in foos)
{
theSession.Store(foo);
}

foreach (var bar in bars)
{
theSession.Store(bar);
}

theSession.SaveChanges();

var includedFoos = new Dictionary<Guid, Foo>();

var queriedBars = theSession.Query<Bar>()
.Include(bar => bar.FooId, dictionary: includedFoos)
.ToPagedList(pageNumber: 1, pageSize: 4);

foreach (var queriedBar in queriedBars)
{
includedFoos.ShouldContainKey(key: queriedBar.FooId);
}
}
}

0 comments on commit 67d5b7d

Please sign in to comment.