public async Task TakeLastSingle() { // arrange var typeInspector = new DefaultTypeInspector(); IExtendedType sourceType = typeInspector.GetType(typeof(List <string>)); IPagingProvider pagingProvider = new QueryableCursorPagingProvider(); IPagingHandler pagingHandler = pagingProvider.CreateHandler(sourceType, default); var list = new List <string> { "f", "g" }; var pagingDetails = new CursorPagingArguments(last: 1); var context = new MockContext(pagingDetails); // act var connection = (Connection)await pagingHandler.SliceAsync(context, list); // assert Assert.Collection(connection.Edges, t => { Assert.Equal("g", t.Node); Assert.Equal(1, GetPositionFromCursor(t.Cursor)); }); Assert.True( connection.Info.HasPreviousPage, "HasPreviousPage"); Assert.False( connection.Info.HasNextPage, "HasNextPage"); }
public async Task HasPrevious_True() { // arrange var typeInspector = new DefaultTypeInspector(); IExtendedType sourceType = typeInspector.GetType(typeof(List <string>)); IPagingProvider pagingProvider = new QueryableCursorPagingProvider(); IPagingHandler pagingHandler = pagingProvider.CreateHandler(sourceType, default); var list = new List <string> { "a", "b", "c", "d", "e", "f", "g" }; var pagingDetails = new CursorPagingArguments(first: 1); var context = new MockContext(pagingDetails); var connection = (Connection)await pagingHandler.SliceAsync(context, list); pagingDetails = new CursorPagingArguments(after: connection.Info.EndCursor, first: 2); context = new MockContext(pagingDetails); // act connection = (Connection)await pagingHandler.SliceAsync(context, list); // assert Assert.True(connection.Info.HasPreviousPage); }