@@ -119,7 +119,7 @@ public void Build_WithUnsupportedScheme_ThrowsNotSupportedException()
119119 [ Theory ]
120120 [ InlineData ( "npipe://./pipe/docker_engine" , typeof ( NPipe . DockerHandlerFactory ) ) ]
121121 [ InlineData ( "unix:/var/run/docker.sock" , typeof ( Unix . DockerHandlerFactory ) ) ]
122- public void ResolveTransportFactory_UsesExpectedFactory_ForSocketSchemes ( string endpoint , Type expectedFactoryType )
122+ public void ResolveTransportFactory_UsesExpectedFactory_WhenSocketSchemeIsProvided ( string endpoint , Type expectedFactoryType )
123123 {
124124 var builder = new TestDockerClientBuilder ( ) ;
125125
@@ -129,7 +129,7 @@ public void ResolveTransportFactory_UsesExpectedFactory_ForSocketSchemes(string
129129 }
130130
131131 [ Fact ]
132- public void ResolveTransportFactory_WithHttpScheme_UsesConfiguredDefaultHttpFactory ( )
132+ public void ResolveTransportFactory_UsesExpectedFactory_WhenHttpSchemeIsProvided ( )
133133 {
134134 var builder = new TestDockerClientBuilder ( ) ;
135135
@@ -143,30 +143,79 @@ public void ResolveTransportFactory_WithHttpScheme_UsesConfiguredDefaultHttpFact
143143 }
144144
145145 [ Fact ]
146- public void Build_WithExplicitTransport_UsesProvidedFactoryAndOptions ( )
146+ public void Build_PreservesClientOptionsAndLogger_WhenSetBeforeTransportSelection ( )
147147 {
148148 var transportFactory = new FakeTransportFactory ( ) ;
149149
150150 var transportOptions = new FakeTransportOptions ( ) ;
151151
152+ const string headerName = "x-test" ;
153+ const string headerValue = "value" ;
154+
155+ var apiVersion = new Version ( 1 , 52 ) ;
156+ var endpoint = new Uri ( "http://localhost:2375" ) ;
157+ var authProvider = new PassThroughAuthProvider ( true ) ;
158+ var timeout = TimeSpan . FromSeconds ( 1 ) ;
159+ var logger = NullLogger . Instance ;
160+
161+ _ = new DockerClientBuilder ( )
162+ . WithApiVersion ( apiVersion )
163+ . WithEndpoint ( endpoint )
164+ . WithAuthProvider ( authProvider )
165+ . WithHeader ( headerName , headerValue )
166+ . WithTimeout ( timeout )
167+ . WithLogger ( logger )
168+ . WithTransportOptions ( transportFactory , transportOptions )
169+ . Build ( ) ;
170+
171+ Assert . Equal ( apiVersion , transportFactory . LastClientOptions . ApiVersion ) ;
172+ Assert . Equal ( endpoint , transportFactory . LastClientOptions . Endpoint ) ;
173+ Assert . Same ( authProvider , transportFactory . LastClientOptions . AuthProvider ) ;
174+ Assert . Equal ( headerValue , transportFactory . LastClientOptions . Headers [ headerName ] ) ;
175+ Assert . Equal ( timeout , transportFactory . LastClientOptions . Timeout ) ;
176+ Assert . Same ( logger , transportFactory . LastLogger ) ;
177+ Assert . Equal ( 1 , transportFactory . TypedCreateHandlerCallCount ) ;
178+ Assert . Same ( transportOptions , transportFactory . LastTransportOptions ) ;
179+ }
180+
181+ [ Fact ]
182+ public void Build_PreservesClientOptionsAndLogger_WhenSetAfterTransportSelection ( )
183+ {
184+ var transportFactory = new FakeTransportFactory ( ) ;
185+
186+ var transportOptions = new FakeTransportOptions ( ) ;
187+
188+ const string headerName = "x-test" ;
189+ const string headerValue = "value" ;
190+
191+ var apiVersion = new Version ( 1 , 52 ) ;
192+ var endpoint = new Uri ( "http://localhost:2375" ) ;
193+ var authProvider = new PassThroughAuthProvider ( true ) ;
194+ var timeout = TimeSpan . FromSeconds ( 5 ) ;
195+ var logger = NullLogger . Instance ;
196+
152197 _ = new DockerClientBuilder ( )
153198 . WithTransportOptions ( transportFactory , transportOptions )
154- . WithEndpoint ( new Uri ( "http://localhost:2375" ) )
155- . WithApiVersion ( new Version ( 1 , 52 ) )
156- . WithHeader ( "x-test" , "value" )
157- . WithTimeout ( TimeSpan . FromSeconds ( 1 ) )
199+ . WithApiVersion ( apiVersion )
200+ . WithEndpoint ( endpoint )
201+ . WithAuthProvider ( authProvider )
202+ . WithHeader ( headerName , headerValue )
203+ . WithTimeout ( timeout )
204+ . WithLogger ( logger )
158205 . Build ( ) ;
159206
207+ Assert . Equal ( apiVersion , transportFactory . LastClientOptions . ApiVersion ) ;
208+ Assert . Equal ( endpoint , transportFactory . LastClientOptions . Endpoint ) ;
209+ Assert . Same ( authProvider , transportFactory . LastClientOptions . AuthProvider ) ;
210+ Assert . Equal ( headerValue , transportFactory . LastClientOptions . Headers [ headerName ] ) ;
211+ Assert . Equal ( timeout , transportFactory . LastClientOptions . Timeout ) ;
212+ Assert . Same ( logger , transportFactory . LastLogger ) ;
160213 Assert . Equal ( 1 , transportFactory . TypedCreateHandlerCallCount ) ;
161214 Assert . Same ( transportOptions , transportFactory . LastTransportOptions ) ;
162- Assert . Equal ( "http" , transportFactory . LastClientOptions . Endpoint . Scheme ) ;
163- Assert . Equal ( "value" , transportFactory . LastClientOptions . Headers [ "x-test" ] ) ;
164- Assert . Equal ( new Version ( 1 , 52 ) , transportFactory . LastClientOptions . ApiVersion ) ;
165- Assert . Equal ( TimeSpan . FromSeconds ( 1 ) , transportFactory . LastClientOptions . Timeout ) ;
166215 }
167216
168217 [ Fact ]
169- public void Build_PreservesOriginalEndpointInClientOptions_WhenTransportNormalizesEndpoint ( )
218+ public void Build_PreservesEndpointInClientOptions_WhenTransportNormalizesEndpoint ( )
170219 {
171220 var transportFactory = new FakeTransportFactory ( ) ;
172221
@@ -183,7 +232,7 @@ public void Build_PreservesOriginalEndpointInClientOptions_WhenTransportNormaliz
183232 }
184233
185234 [ Fact ]
186- public void WithTransportOptions_ReturnsTypedBuilder_ForBuiltInTransports ( )
235+ public void WithTransportOptions_ReturnsTypedBuilder_WhenBuiltInTransportIsSelected ( )
187236 {
188237 var builder = new DockerClientBuilder ( ) ;
189238
@@ -229,11 +278,14 @@ private sealed class FakeTransportFactory : IDockerHandlerFactory<FakeTransportO
229278
230279 public ClientOptions LastClientOptions { get ; private set ; } = null ! ;
231280
281+ public ILogger LastLogger { get ; private set ; } = null ! ;
282+
232283 public ResolvedTransport CreateHandler ( FakeTransportOptions transportOptions , ClientOptions clientOptions , ILogger logger )
233284 {
234285 TypedCreateHandlerCallCount ++ ;
235286 LastTransportOptions = transportOptions ;
236287 LastClientOptions = clientOptions ;
288+ LastLogger = logger ;
237289
238290 return new ResolvedTransport ( new HttpClientHandler ( ) , clientOptions . Endpoint ) ;
239291 }
0 commit comments