protected async Task <IEnumerable <TItem> > GetAllPagesFromApi <TItem>(AdobeQueryBuilder query, int pageSize = 1000) { var items = new List <TItem>(); var page = 0; ApiResponse <AdobeRowResponse <TItem> > response; do { var uri = query .WithParam("limit", pageSize.ToString()) .WithParam("page", page.ToString()) .Build(); response = await HttpClient.GetApiResponse <AdobeRowResponse <TItem> >(uri); if (response == null || !response.HasValue) { throw new ApiException(response?.Error); } items.AddRange(response.Value.Content); page++; } while (response.Value.TotalElements > 0 && !response.Value.LastPage); return(items); }
public void WithParam_ShouldAddToQuery() { // Arrange const string paramKey = "key"; const string paramValue = "value"; // Act var result = _queryBuilder .WithParam(paramKey, paramValue) .Build(); // Assert var query = result.Query; var expectedQuery = $"?{paramKey}={paramValue}"; Assert.That(query, Is.EqualTo(expectedQuery)); }