88using System . Linq ;
99using System . Threading ;
1010using System . Threading . Tasks ;
11- using Elastic . Elasticsearch . Xunit . XunitPlumbing ;
12- using Elastic . Transport ;
11+ using Elastic . Transport . Tests . Plumbing ;
1312using FluentAssertions ;
14- using Nest ;
15- using Tests . Core . Client . Settings ;
13+ using Xunit ;
1614
17- namespace Tests . ClientConcepts . ConnectionPooling . Dispose
15+ namespace Elastic . Transport . Tests
1816{
1917 public class ResponseBuilderDisposeTests
2018 {
21- private readonly IConnectionSettingsValues _settings = new AlwaysInMemoryConnectionSettings ( ) . DisableDirectStreaming ( false ) ;
22- private readonly IConnectionSettingsValues _settingsDisableDirectStream = new AlwaysInMemoryConnectionSettings ( ) . DisableDirectStreaming ( ) ;
19+ private readonly IConnectionConfigurationValues _settings = InMemoryConnectionFactory . Create ( ) . DisableDirectStreaming ( false ) ;
20+ private readonly IConnectionConfigurationValues _settingsDisableDirectStream = InMemoryConnectionFactory . Create ( ) . DisableDirectStreaming ( ) ;
2321
24- [ U ] public async Task ResponseWithHttpStatusCode ( ) => await AssertRegularResponse ( false , 1 ) ;
22+ [ Fact ] public async Task ResponseWithHttpStatusCode ( ) => await AssertRegularResponse ( false , 1 ) ;
2523
26- [ U ] public async Task ResponseBuilderWithNoHttpStatusCode ( ) => await AssertRegularResponse ( false ) ;
24+ [ Fact ] public async Task ResponseBuilderWithNoHttpStatusCode ( ) => await AssertRegularResponse ( false ) ;
2725
28- [ U ] public async Task ResponseWithHttpStatusCodeDisableDirectStreaming ( ) =>
26+ [ Fact ] public async Task ResponseWithHttpStatusCodeDisableDirectStreaming ( ) =>
2927 await AssertRegularResponse ( true , 1 ) ;
3028
31- [ U ] public async Task ResponseBuilderWithNoHttpStatusCodeDisableDirectStreaming ( ) =>
29+ [ Fact ] public async Task ResponseBuilderWithNoHttpStatusCodeDisableDirectStreaming ( ) =>
3230 await AssertRegularResponse ( true ) ;
3331
3432 private async Task AssertRegularResponse ( bool disableDirectStreaming , int ? statusCode = null )
@@ -41,7 +39,7 @@ private async Task AssertRegularResponse(bool disableDirectStreaming, int? statu
4139 } ;
4240
4341 var stream = new TrackDisposeStream ( ) ;
44- var response = ResponseBuilder . ToResponse < RootNodeInfoResponse > ( requestData , null , statusCode , null , stream ) ;
42+ var response = ResponseBuilder . ToResponse < TestResponse > ( requestData , null , statusCode , null , stream ) ;
4543 response . Should ( ) . NotBeNull ( ) ;
4644
4745 memoryStreamFactory . Created . Count ( ) . Should ( ) . Be ( disableDirectStreaming ? 1 : 0 ) ;
@@ -55,7 +53,7 @@ private async Task AssertRegularResponse(bool disableDirectStreaming, int? statu
5553
5654 stream = new TrackDisposeStream ( ) ;
5755 var ct = new CancellationToken ( ) ;
58- response = await ResponseBuilder . ToResponseAsync < RootNodeInfoResponse > ( requestData , null , statusCode , null , stream ,
56+ response = await ResponseBuilder . ToResponseAsync < TestResponse > ( requestData , null , statusCode , null , stream ,
5957 cancellationToken : ct ) ;
6058 response . Should ( ) . NotBeNull ( ) ;
6159 memoryStreamFactory . Created . Count ( ) . Should ( ) . Be ( disableDirectStreaming ? 2 : 0 ) ;
@@ -67,14 +65,14 @@ private async Task AssertRegularResponse(bool disableDirectStreaming, int? statu
6765 stream . IsDisposed . Should ( ) . BeTrue ( ) ;
6866 }
6967
70- [ U ] public async Task StreamResponseWithHttpStatusCode ( ) => await AssertStreamResponse ( false , 200 ) ;
68+ [ Fact ] public async Task StreamResponseWithHttpStatusCode ( ) => await AssertStreamResponse ( false , 200 ) ;
7169
72- [ U ] public async Task StreamResponseBuilderWithNoHttpStatusCode ( ) => await AssertStreamResponse ( false ) ;
70+ [ Fact ] public async Task StreamResponseBuilderWithNoHttpStatusCode ( ) => await AssertStreamResponse ( false ) ;
7371
74- [ U ] public async Task StreamResponseWithHttpStatusCodeDisableDirectStreaming ( ) =>
72+ [ Fact ] public async Task StreamResponseWithHttpStatusCodeDisableDirectStreaming ( ) =>
7573 await AssertStreamResponse ( true , 1 ) ;
7674
77- [ U ] public async Task StreamResponseBuilderWithNoHttpStatusCodeDisableDirectStreaming ( ) =>
75+ [ Fact ] public async Task StreamResponseBuilderWithNoHttpStatusCodeDisableDirectStreaming ( ) =>
7876 await AssertStreamResponse ( true ) ;
7977
8078 private async Task AssertStreamResponse ( bool disableDirectStreaming , int ? statusCode = null )
@@ -88,21 +86,22 @@ private async Task AssertStreamResponse(bool disableDirectStreaming, int? status
8886 } ;
8987
9088 var stream = new TrackDisposeStream ( ) ;
91- var response = ResponseBuilder . ToResponse < RootNodeInfoResponse > ( requestData , null , statusCode , null , stream ) ;
89+ var response = ResponseBuilder . ToResponse < TestResponse > ( requestData , null , statusCode , null , stream ) ;
9290 response . Should ( ) . NotBeNull ( ) ;
9391
9492 memoryStreamFactory . Created . Count ( ) . Should ( ) . Be ( disableDirectStreaming ? 1 : 0 ) ;
9593 stream . IsDisposed . Should ( ) . Be ( true ) ;
9694
9795 stream = new TrackDisposeStream ( ) ;
9896 var ct = new CancellationToken ( ) ;
99- response = await ResponseBuilder . ToResponseAsync < RootNodeInfoResponse > ( requestData , null , statusCode , null , stream ,
97+ response = await ResponseBuilder . ToResponseAsync < TestResponse > ( requestData , null , statusCode , null , stream ,
10098 cancellationToken : ct ) ;
10199 response . Should ( ) . NotBeNull ( ) ;
102100 memoryStreamFactory . Created . Count ( ) . Should ( ) . Be ( disableDirectStreaming ? 2 : 0 ) ;
103101 stream . IsDisposed . Should ( ) . Be ( true ) ;
104102 }
105103
104+
106105 private class TrackDisposeStream : MemoryStream
107106 {
108107 public TrackDisposeStream ( ) { }
0 commit comments