Esempio n. 1
0
        public async Task setup_scenario()
        {
            var throttleManager = new StubThrottleManager {
                Sync = new StubThrottleSync(ConcurrentRequests)
            };

            _expectedResponse = new HttpResponseMessage(HttpStatusCode.Accepted);
            var baseHttpClient = new StubHttpClient(_expectedResponse);
            var configuration  = new ThrottlingConfiguration {
                ThrottlePolicy = "default"
            };
            var httpClient = baseHttpClient.AddThrottling(configuration, throttleManager);

            _actualResponse = await httpClient.GetAsync("/ping");
        }
Esempio n. 2
0
        public void setup_scenario()
        {
            var throttleManager = new StubThrottleManager {
                Sync = new StubThrottleSync(ExpectedMaxConcurrentRequests)
            };

            _baseHttpClient = new CountingHttpClient();
            var configuration = new ThrottlingConfiguration {
                ThrottlePolicy = "default"
            };
            var httpClient = _baseHttpClient.AddThrottling(configuration, throttleManager);

            var tasks = Enumerable.Range(1, ExpectedTotalRequests).Select(c => httpClient.GetAsync("/ping")).ToArray();

            Task.WhenAll(tasks).Wait(5000);
        }