private IRequestPipeline CreatePipeline( Func <IEnumerable <Uri>, IConnectionPool> setupPool, Func <ConnectionSettings, ConnectionSettings> settingsSelector = null, IDateTimeProvider dateTimeProvider = null) { var pool = setupPool(new[] { TestClient.CreateNode(), TestClient.CreateNode(9201) }); var settings = new ConnectionSettings(pool, TestClient.CreateConnection()); settings = settingsSelector?.Invoke(settings) ?? settings; return(new FixedPipelineFactory(settings, dateTimeProvider ?? DateTimeProvider.Default).Pipeline); }
//[I] public void ServerTestWhenThrowExceptionsDisabled() { var settings = new ConnectionSettings(TestClient.CreateNode(_port)); var client = new ElasticClient(settings); var response = client.GetMapping <Project>(s => s.Index("doesntexist")); #if DOTNETCORE // HttpClient does not throw on "known error" status codes (i.e. 404) thus OriginalException should not be set response.CallDetails.OriginalException.Should().BeNull(); #else response.CallDetails.OriginalException.Should().NotBeNull(); #endif response.CallDetails.ServerError.Should().NotBeNull(); response.CallDetails.ServerError.Status.Should().BeGreaterThan(0); }
//[I] public void ServerTestWhenThrowExceptionsEnabled() { var settings = new ConnectionSettings(TestClient.CreateNode(_port)) .ThrowExceptions(); var client = new ElasticClient(settings); var exception = Assert.Throws <ElasticsearchClientException>(() => client.GetMapping <Project>(s => s.Index("doesntexist"))); #if DOTNETCORE // HttpClient does not throw on "known error" status codes (i.e. 404) thus the inner exception should not be set exception.InnerException.Should().BeNull(); #else exception.InnerException.Should().NotBeNull(); #endif exception.Response.Should().NotBeNull(); exception.Response.ServerError.Should().NotBeNull(); exception.Response.ServerError.Status.Should().BeGreaterThan(0); }