@@ -20,7 +20,7 @@ public async Task CheckHealthAsync_WhenContextNull_ThrowArgumentNullException()
2020 // Arrange
2121 var serviceProvider = Substitute . For < IServiceProvider > ( ) ;
2222 var optionsMonitor = Substitute . For < IOptionsMonitor < ElasticsearchOptions > > ( ) ;
23- var check = new ElasticsearchHealthCheck ( serviceProvider , optionsMonitor ) ;
23+ using var check = new ElasticsearchHealthCheck ( serviceProvider , optionsMonitor ) ;
2424
2525 // Act
2626 async Task Act ( ) => _ = await check . CheckHealthAsync ( null ! , default ) ;
@@ -37,7 +37,7 @@ public async Task CheckHealthAsync_WhenCancellationTokenIsCancelled_ShouldReturn
3737 var serviceProvider = Substitute . For < IServiceProvider > ( ) ;
3838 var optionsMonitor = Substitute . For < IOptionsMonitor < ElasticsearchOptions > > ( ) ;
3939
40- var check = new ElasticsearchHealthCheck ( serviceProvider , optionsMonitor ) ;
40+ using var check = new ElasticsearchHealthCheck ( serviceProvider , optionsMonitor ) ;
4141 var context = new HealthCheckContext
4242 {
4343 Registration = new HealthCheckRegistration ( testName , check , null , null ) ,
@@ -65,7 +65,7 @@ public async Task CheckHealthAsync_WhenOptionsAreNull_ShouldReturnUnhealthy()
6565 var serviceProvider = Substitute . For < IServiceProvider > ( ) ;
6666 var optionsMonitor = Substitute . For < IOptionsMonitor < ElasticsearchOptions > > ( ) ;
6767
68- var check = new ElasticsearchHealthCheck ( serviceProvider , optionsMonitor ) ;
68+ using var check = new ElasticsearchHealthCheck ( serviceProvider , optionsMonitor ) ;
6969 var context = new HealthCheckContext
7070 {
7171 Registration = new HealthCheckRegistration ( testName , check , null , null ) ,
@@ -112,7 +112,7 @@ public async Task CheckHealthAsync_WithKeyedService_ShouldUseKeyedService()
112112
113113 var serviceProvider = new ServiceCollection ( ) . AddKeyedSingleton ( serviceKey , client ) . BuildServiceProvider ( ) ;
114114
115- var healthCheck = new ElasticsearchHealthCheck ( serviceProvider , optionsMonitor ) ;
115+ using var healthCheck = new ElasticsearchHealthCheck ( serviceProvider , optionsMonitor ) ;
116116 var context = new HealthCheckContext
117117 {
118118 Registration = new HealthCheckRegistration (
@@ -163,7 +163,7 @@ public async Task CheckHealthAsync_WithoutKeyedService_ShouldUseDefaultService()
163163
164164 var serviceProvider = new ServiceCollection ( ) . AddSingleton ( client ) . BuildServiceProvider ( ) ;
165165
166- var healthCheck = new ElasticsearchHealthCheck ( serviceProvider , optionsMonitor ) ;
166+ using var healthCheck = new ElasticsearchHealthCheck ( serviceProvider , optionsMonitor ) ;
167167 var context = new HealthCheckContext
168168 {
169169 Registration = new HealthCheckRegistration (
@@ -214,7 +214,7 @@ public async Task CheckHealthAsync_WhenConnectionFails_ShouldReturnUnhealthy()
214214
215215 var serviceProvider = new ServiceCollection ( ) . AddSingleton ( client ) . BuildServiceProvider ( ) ;
216216
217- var healthCheck = new ElasticsearchHealthCheck ( serviceProvider , optionsMonitor ) ;
217+ using var healthCheck = new ElasticsearchHealthCheck ( serviceProvider , optionsMonitor ) ;
218218 var context = new HealthCheckContext
219219 {
220220 Registration = new HealthCheckRegistration (
0 commit comments