public void TokensShouldBeGeneratedAsPerTheTokenIndexPairs() { foreach (var tokenIndexPair in TokenIndexPairs) { Assert.AreEqual(tokenIndexPair.Item1, PageTokenGen.NumberToToken(tokenIndexPair.Item2)); } }
/// <summary> /// Executes Requests in a standard paged manner. /// </summary> /// <param name="range"></param> /// <param name="cancellationToken"></param> /// <returns></returns> public async Task <IEnumerable <TResponseItem> > ExecutePagedAsync(RequestRange range, CancellationToken cancellationToken = default(CancellationToken)) { var result = new List <TResponseItem>(); var pageTokenGen = new PageTokenGenerator(); ListRequestBuilder.MaxResults = range.MaxResultsPerPage; var nextPageToken = pageTokenGen.NumberToToken(range.StartIndex); while (nextPageToken != null && result.Count < range.NumberOfItems) { ListRequestBuilder.PageToken = nextPageToken; var response = await ListRequestBuilder.CreateRequest().ExecuteAsync(cancellationToken).ConfigureAwait(false); var responseItems = response.GetResponseItems <TResponseItem>(); result.AddRange(responseItems); nextPageToken = response.GetNextPageToken(); } return(result); }