public IAsyncEnumerable <ITestRun> All() { var statusLocator = _testStatus switch { TestStatus.FAILED => "status:FAILURE", TestStatus.SUCCESSFUL => "status:SUCCESS", TestStatus.IGNORED => "ignored:true", _ => throw new Exception($"Unsupported filter by test status {_testStatus}") }; var count = Utility.SelectRestApiCountForPagedRequests(_limitResults, _pageSize); var parameters = Utility.ListOfNotNull( count?.Let(val => $"count:{val}"), _affectedProjectId?.Let(val => $"affectedProject:{val}"), _buildId?.Let(val => $"build:{val}"), _testId?.Let(val => $"test:{val}"), _expandMultipleInvocations.Let(val => $"expandInvocations:{val.ToString().ToLower()}"), statusLocator ); if (parameters.IsEmpty()) { throw new ArgumentException("At least one parameter should be specified"); } var sequence = new Paged <ITestRun, TestOccurrenceListDto>( Instance, async() => { var testOccurrencesLocator = String.Join(",", parameters); // LOG.debug("Retrieving test occurrences from ${instance.serverUrl} using query '$testOccurrencesLocator'") return(await Service .TestOccurrences(testOccurrencesLocator, TestOccurrenceDto.FILTER) .ConfigureAwait(false)); }, async(list) => { return(await Task.Run(() => { var runs = list.Items.Select(test => new TestRun(test)).ToArray(); return new Page <ITestRun>( runs, list.NextHref ); }).ConfigureAwait(false)); } ); return(_limitResults.HasValue ? sequence.Take(_limitResults.Value) : sequence); }