public async Task Last_LastPage_ReturnsNull() { ClientRequestParameters parameters = new ClientRequestParameters() { Pagination = new ClientRequestPagination() { Page = 3 } }; ClientResponse <IList <ModelBase> > response = UKFastClientTests.GetListResponse(new List <ModelBase>(), 3); Paginated <ModelBase> paginated = new Paginated <ModelBase>(null, null, parameters, response); Paginated <ModelBase> next = await paginated.Next(); Assert.IsNull(next); }
/// <summary> /// GetAllAsync retrieves all pages for provided func /// </summary> /// <typeparam name="T">Type of model</typeparam> /// <param name="func">Implementation of GetPaginatedAsyncFunc</param> /// <param name="parameters">Request parameters</param> /// <returns></returns> public async Task <IList <T> > GetAllAsync <T>(GetPaginatedAsyncFunc <T> func, ClientRequestParameters parameters = null) where T : ModelBase { parameters = InitialisePaginationParameters(parameters); List <T> items = new List <T>(); Paginated <T> p = await func(parameters); while (p != null) { if (p.Items?.Count > 0) { items.AddRange(p.Items); } p = await p.Next(); } return(items); }