public async Task Test_Analytics(string file, HttpStatusCode httpStatusCode, Type errorType, bool readOnly) { var retryOrchestrator = CreateRetryOrchestrator(); using (var response = ResourceHelper.ReadResourceAsStream(@"Documents\Analytics\" + file)) { var buffer = new byte[response.Length]; response.Read(buffer, 0, buffer.Length); var responses = GetResponses(20, buffer, httpStatusCode); var client = MockedHttpClients.AnalyticsClient(responses); using var cts = new CancellationTokenSource(); cts.CancelAfter(1000); var options = new AnalyticsOptions(). Timeout(TimeSpan.FromSeconds(1000)).CancellationToken(cts.Token).Readonly(readOnly); var query = new AnalyticsRequest("SELECT * FROM `bar`;") { ClientContextId = options.ClientContextIdValue, NamedParameters = options.NamedParameters, PositionalArguments = options.PositionalParameters, ReadOnly = options.ReadonlyValue, Idempotent = options.ReadonlyValue }; // ReSharper disable once PossibleInvalidOperationException query.WithTimeout(options.TimeoutValue.Value); query.Priority(options.PriorityValue); query.Token = options.Token; async Task <IAnalyticsResult <dynamic> > Send() { var client1 = client; return(await client1.QueryAsync <dynamic>(query, options.Token)); } await AssertThrowsIfExpectedAsync(errorType, () => retryOrchestrator.RetryAsync(Send, query)); } }