using System; using System.Collections.Generic; using System.Threading.Tasks; using NSubstitute; using Octokit.Internal; using Xunit; namespace Octokit.Tests.Models { public class ReadOnlyPagedCollectionTests { public class TheGetNextPageMethod { [Fact] public async Task ReturnsTheNextPage() { var nextPageUrl = new Uri("https://example.com/page/2"); var nextPageResponse = Task.Factory.StartNew>>(() => new ApiResponse> {BodyAsObject = new List {new object(), new object()}}); var links = new Dictionary {{"next", nextPageUrl}}; var scopes = new List(); var response = new ApiResponse> { BodyAsObject = new List(), ApiInfo = new ApiInfo(links, scopes, scopes, "etag", new RateLimit(new Dictionary())) }; var connection = Substitute.For(); connection.Get>(nextPageUrl, null, null).Returns(nextPageResponse); var pagedCollection = new ReadOnlyPagedCollection( response, nextPageUri => connection.Get>(nextPageUrl, null, null)); var nextPage = await pagedCollection.GetNextPage(); Assert.NotNull(nextPage); Assert.Equal(2, nextPage.Count); } } } }