@@ -356,6 +356,30 @@ public void ApplyPagination_WithEmptyDataset_ReturnsEmptyResult()
356356 // Assert
357357 Assert . Empty ( result ) ;
358358 }
359+
360+ [ Fact ]
361+ public async Task Issue_Scenario_PageTwoOfOneTotal_ReturnsLastPageData ( )
362+ {
363+ // Arrange - exact scenario from the issue: 6 total resources, page size 10, requesting page 2
364+ var query = GetTestData ( ) ; // 5 items
365+ var largePageQuery = query . Take ( 6 ) . AsQueryable ( ) ; // Take 6 to match issue example
366+ var pagination = new PaginationParameters { Number = 2 , Size = 10 } ; // page 2, size 10
367+
368+ // Act
369+ var result = largePageQuery . ApplyPagination ( pagination ) . ToList ( ) ;
370+ var meta = await largePageQuery . CreatePaginationMetaAsync ( pagination ) ;
371+
372+ // Assert - Should return the first page (which is also the last page) with data
373+ Assert . Equal ( 5 , result . Count ) ; // All 5 items should be returned (first page = last page)
374+ Assert . Equal ( 5 , meta . TotalResources ) ;
375+ Assert . Equal ( 1 , meta . TotalPages ) ; // Only 1 page with size 10 for 5 items
376+ Assert . Equal ( 1 , meta . CurrentPage ) ; // Should be clamped to page 1 (the last available page)
377+ Assert . Equal ( 10 , meta . PageSize ) ;
378+
379+ // Verify we got actual data, not empty results
380+ Assert . True ( result . Any ( ) ) ;
381+ Assert . Equal ( 1 , result . First ( ) . Id ) ;
382+ }
359383}
360384
361385// Helper extension to simulate async for in-memory testing
0 commit comments