public async void StaticConnectionPool_DoesNotThrowOrRetry_On_401_Async()
		{
			var nodes = new Uri[] {
				new Uri("http://*****:*****@localhost:9200"),
				new Uri("http://*****:*****@localhost:9201")
			};
			var pool = new StaticConnectionPool(nodes);
			var settings = new ConnectionSettings(pool)
				.MaximumRetries(3);
			var client = new ElasticClient(settings);
			var r = await client.RootNodeInfoAsync();
			r.IsValid.Should().BeFalse();
			r.ConnectionStatus.HttpStatusCode.Should().Be(401);
			r.ConnectionStatus.Metrics.Requests.Count.Should().Be(1);
			r.ConnectionStatus.Metrics.Requests[0].RequestType.Should().Be(RequestType.Ping);
			r.ConnectionStatus.NumberOfRetries.Should().Be(0);
		}
		public void StaticConnectionPool_ThrowsAndDoesNotRetry_On_401_Async()
		{
			var nodes = new Uri[] {
				new Uri("http://*****:*****@localhost:9200"),
				new Uri("http://*****:*****@localhost:9201")
			};
			var pool = new StaticConnectionPool(nodes);
			var settings = new ConnectionSettings(pool)
				.ThrowOnElasticsearchServerExceptions()
				.MaximumRetries(3);

			var client = new ElasticClient(settings);
			var e = Assert.Throws<ElasticsearchServerException>(async () => await client.RootNodeInfoAsync());
			e.Status.Should().Be(401);
		}
		public async void Unauthorized_With_Ping_Disabled_Async()
		{
			var nodes = new Uri[] {
				new Uri("http://*****:*****@localhost:9200"),
				new Uri("http://*****:*****@localhost:9201")
			};
			var pool = new StaticConnectionPool(nodes);
			var settings = new ConnectionSettings(pool)
				.MaximumRetries(3)
				.DisablePing();
			var client = new ElasticClient(settings);
			var r = await client.RootNodeInfoAsync();
			r.IsValid.Should().BeFalse();
			r.ConnectionStatus.HttpStatusCode.Should().Be(401);
			r.ConnectionStatus.Metrics.Requests.Count.Should().Be(1);
			r.ConnectionStatus.Metrics.Requests[0].RequestType.Should().Be(RequestType.ElasticsearchCall);
			r.ConnectionStatus.NumberOfRetries.Should().Be(0);
		}
 public void OnRequestCompletedIsCalled()
 {
     var counter = 0;
     var connectionPool = new SingleNodeConnectionPool(new Uri("http://localhost:9200"));
     var settings = new ConnectionSettings(connectionPool, new InMemoryConnection())
         .OnRequestCompleted(r => counter++);
     var client = new ElasticClient(settings);
     client.RootNodeInfo();
     counter.Should().Be(1);
     client.RootNodeInfoAsync();
     counter.Should().Be(2);
 }