File tree 2 files changed +18
-1
lines changed
src/GreenDonut.Data/Extensions
test/GreenDonut.Data.EntityFramework.Tests
2 files changed +18
-1
lines changed Original file line number Diff line number Diff line change @@ -112,7 +112,7 @@ public static ImmutableArray<PageCursor> CreateRelativeForwardCursors<T>(this Pa
112
112
return [ ] ;
113
113
}
114
114
115
- var totalPages = ( page . TotalCount ?? 0 ) / ( page . RequestedSize ?? 10 ) ;
115
+ var totalPages = Math . Ceiling ( ( double ) ( page . TotalCount ?? 0 ) / ( page . RequestedSize ?? 10 ) ) ;
116
116
117
117
if ( page . Index >= totalPages )
118
118
{
Original file line number Diff line number Diff line change @@ -1222,6 +1222,23 @@ await ctx.Brands.Where(t => t.GroupId == 2).OrderBy(t => t.Name).ThenBy(t => t.I
1222
1222
await Assert . ThrowsAsync < ArgumentException > ( Error ) ;
1223
1223
}
1224
1224
1225
+ [ Fact ]
1226
+ public async Task RequestedSize_Not_Evenly_Divisible_By_TotalCount ( )
1227
+ {
1228
+ // Arrange
1229
+ var connectionString = CreateConnectionString ( ) ;
1230
+ await SeedAsync ( connectionString ) ;
1231
+ await using var context = new TestContext ( connectionString ) ;
1232
+ var arguments = new PagingArguments ( 12 ) { EnableRelativeCursors = true } ;
1233
+
1234
+ // Act
1235
+ var first = await context . Brands . OrderBy ( t => t . Name ) . ThenBy ( t => t . Id ) . ToPageAsync ( arguments ) ;
1236
+
1237
+ // Assert
1238
+ Assert . Equal ( 20 , first . TotalCount ) ;
1239
+ Assert . Single ( first . CreateRelativeForwardCursors ( ) ) ;
1240
+ }
1241
+
1225
1242
private static async Task SeedAsync ( string connectionString )
1226
1243
{
1227
1244
await using var context = new TestContext ( connectionString ) ;
You can’t perform that action at this time.
0 commit comments