Skip to content

Commit d722aa4

Browse files
committed
Add test for paginated entity retrieval
Implemented a new test method `GetPagingEntitiesAsync` in the `Tests` class. This method verifies the functionality of retrieving paginated entities from the repository, ensuring the database context is properly set up and that the expected number of items and specific entities are returned.
1 parent e873f5e commit d722aa4

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

src/ClassLibrary.EFCore.Tests/Tests.cs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -237,4 +237,21 @@ public async Task GetPaginatedEntitiesDescendingOrderTypeAsync()
237237
Assert.Equal(10, Assert.IsType<Persone>(entities.Items.First()).Id);
238238
Assert.Contains(query, x => x.Id == 8);
239239
}
240+
241+
[Fact]
242+
public async Task GetPagingEntitiesAsync()
243+
{
244+
using var dbContext = GetDbContext();
245+
var repository = new Repository<Persone, int>(dbContext);
246+
247+
await dbContext.Database.EnsureDeletedAsync();
248+
await dbContext.Database.EnsureCreatedAsync();
249+
250+
var result = await repository.GetAllPagingAsync(pageNumber: 2, pageSize: 5, includes: q => q.Include(p => p.Indirizzo), filter: w => w.Id <= 10);
251+
252+
Assert.NotNull(result);
253+
Assert.Equal(10, result.TotalItems);
254+
Assert.Equal(5, result.Items.Count);
255+
Assert.Contains(result.Items, x => x.Id == 8);
256+
}
240257
}

0 commit comments

Comments
 (0)