Exemple #1
0
        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 statement = "SELECT * FROM `bar`;";
                var options   = new AnalyticsOptions();
                options.Timeout(TimeSpan.FromSeconds(1000));
                options.CancellationToken(cts.Token);
                options.Readonly(readOnly);

                async Task <IAnalyticsResult <dynamic> > Send()
                {
                    var client1 = client;

                    return(await client1.QueryAsync <dynamic>(statement, options));
                }

                var meter = NoopMeter.Instance;
                await AssertThrowsIfExpectedAsync(errorType, () => retryOrchestrator.RetryAsync(Send, AnalyticsRequest.Create(statement, meter.ValueRecorder("analytics"), options)));
            }
        }