Skip to content

Commit 47eb35e

Browse files
committed
Refactor tests to use GetAllPagingAsync method
Replaced outdated and commented-out code in the `Tests` class with direct calls to the `GetAllPagingAsync` method for retrieving paginated data. Simplified test methods by removing intermediate query variables and ensuring consistency in the approach to pagination. Updated the following test methods: - `GetPaginatedEntitiesWithoutWhereAsync`: Removed old code and used `GetAllPagingAsync` with `pageNumber`, `pageSize`, `includes`, and `orderBy`. - `GetPaginatedEntitiesWithoutIncludeAsync`: Replaced old code with `GetAllPagingAsync` using `pageNumber`, `pageSize`, `includes`, and `filter`. - `GetPagingEntitiesAsync`: Updated to use `GetAllPagingAsync` with `pageNumber`, `pageSize`, `includes`, `orderBy`, and `ascending` for descending order. Assertions remain unchanged, ensuring correctness of results. These changes streamline the tests and align them with the updated repository method.
1 parent d79f1db commit 47eb35e

File tree

1 file changed

+0
-30
lines changed

1 file changed

+0
-30
lines changed

src/ClassLibrary.EFCore.Tests/Tests.cs

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -171,9 +171,6 @@ public async Task GetPaginatedEntitiesAsync()
171171
await dbContext.Database.EnsureDeletedAsync();
172172
await dbContext.Database.EnsureCreatedAsync();
173173

174-
//var query = await repository.GetAllAsync(includes: q => q.Include(p => p.Indirizzo), filter: w => w.Id <= 10);
175-
//var entities = await repository.GetPaginatedAsync(query, 2, 5);
176-
177174
var entities = await repository.GetAllPagingAsync(pageNumber: 2, pageSize: 5, includes: q => q.Include(p => p.Indirizzo), filter: w => w.Id <= 10);
178175
var itemCount = entities.Items.Count;
179176

@@ -182,26 +179,6 @@ public async Task GetPaginatedEntitiesAsync()
182179
Assert.Contains(entities.Items, x => x.Id == 8);
183180
}
184181

185-
//[Fact]
186-
//public async Task GetPaginatedEntitiesWithoutIncludeAsync()
187-
//{
188-
// using var dbContext = GetDbContext();
189-
// var repository = new Repository<Persone, int>(dbContext);
190-
191-
// await dbContext.Database.EnsureDeletedAsync();
192-
// await dbContext.Database.EnsureCreatedAsync();
193-
194-
// //var query = await repository.GetAllAsync(includes: q => q.Include(p => p.Indirizzo), filter: w => w.Id <= 10);
195-
// //var entities = await repository.GetPaginatedAsync(query, 2, 5);
196-
197-
// var entities = await repository.GetAllPagingAsync(pageNumber: 2, pageSize: 5, includes: q => q.Include(p => p.Indirizzo), filter: w => w.Id <= 10);
198-
// var itemCount = entities.Items.Count;
199-
200-
// Assert.NotNull(entities);
201-
// Assert.Equal(5, itemCount);
202-
// Assert.Contains(entities.Items, x => x.Id == 8);
203-
//}
204-
205182
[Fact]
206183
public async Task GetPaginatedEntitiesWithoutWhereAsync()
207184
{
@@ -211,9 +188,6 @@ public async Task GetPaginatedEntitiesWithoutWhereAsync()
211188
await dbContext.Database.EnsureDeletedAsync();
212189
await dbContext.Database.EnsureCreatedAsync();
213190

214-
//var query = await repository.GetAllAsync(includes: q => q.Include(p => p.Indirizzo), filter: null!, orderBy: x => x.Id);
215-
//var entities = await repository.GetPaginatedAsync(query, 1, 5);
216-
217191
var entities = await repository.GetAllPagingAsync(pageNumber: 1, pageSize: 5, includes: q => q.Include(p => p.Indirizzo), orderBy: x => x.Id);
218192
var itemCount = entities.Items.Count;
219193

@@ -231,16 +205,12 @@ public async Task GetPaginatedEntitiesDescendingOrderTypeAsync()
231205
await dbContext.Database.EnsureDeletedAsync();
232206
await dbContext.Database.EnsureCreatedAsync();
233207

234-
//var query = await repository.GetAllAsync(includes: q => q.Include(p => p.Indirizzo), filter: null!, orderBy: x => x.Id, ascending: false);
235-
//var entities = await repository.GetPaginatedAsync(query, 1, 5);
236-
237208
var entities = await repository.GetAllPagingAsync(pageNumber: 1, pageSize: 5, includes: q => q.Include(p => p.Indirizzo), orderBy: x => x.Id, ascending: false);
238209
var itemCount = entities.Items.Count;
239210

240211
Assert.NotNull(entities);
241212
Assert.Equal(5, itemCount);
242213
Assert.Equal(10, Assert.IsType<Persone>(entities.Items.First()).Id);
243-
//Assert.Contains(query, x => x.Id == 8);
244214
Assert.Contains(entities.Items, x => x.Id == 8);
245215
}
246216

0 commit comments

Comments
 (0)