Пример #1
0
        public async Task ConnectTimeoutTest()
        {
            HostsFile.Set(_hostname, "128.0.0.1");
            var client = new TransientHttpClient(_uri);

            var timer = Stopwatch.StartNew();

            try
            {
                await new ExecuteOnce(client).ExecuteAsync(() => Task.CompletedTask);
            }
            catch
            {
                _logger.WriteLine(timer.ElapsedMilliseconds.ToString());
            }
        }
Пример #2
0
        public async Task TransientDnsChangeTest()
        {
            HostsFile.Set(_hostname, "127.0.0.1");
            var client = new TransientHttpClient(_uri);

            var timer = Stopwatch.StartNew();

            try
            {
                await new LoopUntilFailure(client).ExecuteAsync(
                    () => Task.Run(() => HostsFile.Set(_hostname, "128.0.0.1")));
            }
            catch
            {
                _logger.WriteLine($"{typeof(IHttpClient).Name} - {timer.ElapsedMilliseconds}");
            }
        }