@@ -25,7 +25,7 @@ namespace MongoDB.Driver.Core.Configuration
2525{
2626 public class ConnectionSettingsTests
2727 {
28- private static readonly ConnectionSettings __defaults = new ConnectionSettings ( ) ;
28+ private static readonly ConnectionSettings __defaults = new ( ) ;
2929
3030 [ Fact ]
3131 public void constructor_should_initialize_instance ( )
@@ -35,6 +35,7 @@ public void constructor_should_initialize_instance()
3535 subject . ApplicationName . Should ( ) . BeNull ( ) ;
3636 subject . AuthenticatorFactory . Should ( ) . BeNull ( ) ;
3737 subject . Compressors . Should ( ) . BeEmpty ( ) ;
38+ subject . ConnectionIdLocalValueProvider . Should ( ) . NotBeNull ( ) ;
3839 subject . LibraryInfo . Should ( ) . BeNull ( ) ;
3940 subject . MaxIdleTime . Should ( ) . Be ( TimeSpan . FromMinutes ( 10 ) ) ;
4041 subject . MaxLifeTime . Should ( ) . Be ( TimeSpan . FromMinutes ( 30 ) ) ;
@@ -90,6 +91,7 @@ public void constructor_with_applicationName_should_initialize_instance()
9091 subject . ApplicationName . Should ( ) . Be ( "app" ) ;
9192 subject . AuthenticatorFactory . Should ( ) . Be ( __defaults . AuthenticatorFactory ) ;
9293 subject . Compressors . Should ( ) . Equal ( __defaults . Compressors ) ;
94+ subject . ConnectionIdLocalValueProvider . Should ( ) . NotBeNull ( ) ;
9395 subject . LibraryInfo . Should ( ) . BeNull ( ) ;
9496 subject . MaxIdleTime . Should ( ) . Be ( __defaults . MaxIdleTime ) ;
9597 subject . MaxLifeTime . Should ( ) . Be ( __defaults . MaxLifeTime ) ;
@@ -105,6 +107,7 @@ public void constructor_with_authenticatorFactory_should_initialize_instance()
105107 subject . ApplicationName . Should ( ) . BeNull ( ) ;
106108 subject . AuthenticatorFactory . Should ( ) . Be ( authenticatorFactory ) ;
107109 subject . Compressors . Should ( ) . BeEquivalentTo ( __defaults . Compressors ) ;
110+ subject . ConnectionIdLocalValueProvider . Should ( ) . NotBeNull ( ) ;
108111 subject . LibraryInfo . Should ( ) . BeNull ( ) ;
109112 subject . MaxIdleTime . Should ( ) . Be ( __defaults . MaxIdleTime ) ;
110113 subject . MaxLifeTime . Should ( ) . Be ( __defaults . MaxLifeTime ) ;
@@ -120,6 +123,7 @@ public void constructor_with_compressors_should_initialize_instance()
120123 subject . ApplicationName . Should ( ) . BeNull ( ) ;
121124 subject . AuthenticatorFactory . Should ( ) . BeNull ( ) ;
122125 subject . Compressors . Should ( ) . Equal ( compressors ) ;
126+ subject . ConnectionIdLocalValueProvider . Should ( ) . NotBeNull ( ) ;
123127 subject . LibraryInfo . Should ( ) . BeNull ( ) ;
124128 subject . MaxIdleTime . Should ( ) . Be ( __defaults . MaxIdleTime ) ;
125129 subject . MaxLifeTime . Should ( ) . Be ( __defaults . MaxLifeTime ) ;
@@ -133,6 +137,7 @@ public void constructor_with_library_info_should_initialize_instance()
133137 subject . ApplicationName . Should ( ) . BeNull ( ) ;
134138 subject . AuthenticatorFactory . Should ( ) . Be ( __defaults . AuthenticatorFactory ) ;
135139 subject . Compressors . Should ( ) . Equal ( __defaults . Compressors ) ;
140+ subject . ConnectionIdLocalValueProvider . Should ( ) . NotBeNull ( ) ;
136141 subject . LibraryInfo . Should ( ) . Be ( new LibraryInfo ( "lib" , "1.0" ) ) ;
137142 subject . MaxIdleTime . Should ( ) . Be ( __defaults . MaxIdleTime ) ;
138143 subject . MaxLifeTime . Should ( ) . Be ( __defaults . MaxLifeTime ) ;
@@ -148,6 +153,7 @@ public void constructor_with_maxIdleTime_should_initialize_instance()
148153 subject . ApplicationName . Should ( ) . BeNull ( ) ;
149154 subject . AuthenticatorFactory . Should ( ) . BeNull ( ) ;
150155 subject . Compressors . Should ( ) . Equal ( __defaults . Compressors ) ;
156+ subject . ConnectionIdLocalValueProvider . Should ( ) . NotBeNull ( ) ;
151157 subject . LibraryInfo . Should ( ) . BeNull ( ) ;
152158 subject . MaxIdleTime . Should ( ) . Be ( maxIdleTime ) ;
153159 subject . MaxLifeTime . Should ( ) . Be ( __defaults . MaxLifeTime ) ;
@@ -163,6 +169,7 @@ public void constructor_with_maxLifeTime_should_initialize_instance()
163169 subject . ApplicationName . Should ( ) . BeNull ( ) ;
164170 subject . AuthenticatorFactory . Should ( ) . BeNull ( ) ;
165171 subject . Compressors . Should ( ) . Equal ( __defaults . Compressors ) ;
172+ subject . ConnectionIdLocalValueProvider . Should ( ) . NotBeNull ( ) ;
166173 subject . LibraryInfo . Should ( ) . BeNull ( ) ;
167174 subject . MaxIdleTime . Should ( ) . Be ( __defaults . MaxIdleTime ) ;
168175 subject . MaxLifeTime . Should ( ) . Be ( maxLifeTime ) ;
@@ -180,6 +187,7 @@ public void With_applicationName_should_return_expected_result()
180187 result . ApplicationName . Should ( ) . Be ( newApplicationName ) ;
181188 result . AuthenticatorFactory . Should ( ) . Be ( subject . AuthenticatorFactory ) ;
182189 result . Compressors . Should ( ) . Equal ( __defaults . Compressors ) ;
190+ result . ConnectionIdLocalValueProvider . Should ( ) . Be ( subject . ConnectionIdLocalValueProvider ) ;
183191 result . LibraryInfo . Should ( ) . BeNull ( ) ;
184192 result . MaxIdleTime . Should ( ) . Be ( subject . MaxIdleTime ) ;
185193 result . MaxLifeTime . Should ( ) . Be ( subject . MaxLifeTime ) ;
@@ -193,11 +201,12 @@ public void With_authenticatorFactories_should_return_expected_result()
193201
194202 var subject = new ConnectionSettings ( authenticatorFactory : oldAuthenticatorFactory ) ;
195203
196- var result = subject . With ( authenticatorFactory : Optional . Create ( newAuthenticatorFactory ) ) ;
204+ var result = subject . WithInternal ( authenticatorFactory : Optional . Create ( newAuthenticatorFactory ) ) ;
197205
198206 result . ApplicationName . Should ( ) . Be ( subject . ApplicationName ) ;
199207 result . AuthenticatorFactory . Should ( ) . Be ( newAuthenticatorFactory ) ;
200208 result . Compressors . Should ( ) . Equal ( subject . Compressors ) ;
209+ result . ConnectionIdLocalValueProvider . Should ( ) . Be ( subject . ConnectionIdLocalValueProvider ) ;
201210 result . LibraryInfo . Should ( ) . BeNull ( ) ;
202211 result . MaxIdleTime . Should ( ) . Be ( subject . MaxIdleTime ) ;
203212 result . MaxLifeTime . Should ( ) . Be ( subject . MaxLifeTime ) ;
@@ -215,6 +224,24 @@ public void With_compressors_should_return_expected_result()
215224 result . ApplicationName . Should ( ) . Be ( subject . ApplicationName ) ;
216225 result . AuthenticatorFactory . Should ( ) . Be ( subject . AuthenticatorFactory ) ;
217226 result . Compressors . Should ( ) . Equal ( newCompressors ) ;
227+ result . ConnectionIdLocalValueProvider . Should ( ) . Be ( subject . ConnectionIdLocalValueProvider ) ;
228+ result . LibraryInfo . Should ( ) . BeNull ( ) ;
229+ result . MaxIdleTime . Should ( ) . Be ( subject . MaxIdleTime ) ;
230+ result . MaxLifeTime . Should ( ) . Be ( subject . MaxLifeTime ) ;
231+ }
232+
233+ [ Fact ]
234+ public void With_ConnectionIdLocalValueProvider_should_return_expected_result ( )
235+ {
236+ Func < long > connectIdLocalValueProvider = ( ) => 1 ;
237+ var subject = new ConnectionSettings ( ) ;
238+
239+ var result = subject . WithInternal ( connectionIdLocalValueProvider : connectIdLocalValueProvider ) ;
240+
241+ result . ApplicationName . Should ( ) . Be ( subject . ApplicationName ) ;
242+ result . AuthenticatorFactory . Should ( ) . Be ( subject . AuthenticatorFactory ) ;
243+ result . Compressors . Should ( ) . Equal ( subject . Compressors ) ;
244+ result . ConnectionIdLocalValueProvider . Should ( ) . Be ( connectIdLocalValueProvider ) ;
218245 result . LibraryInfo . Should ( ) . BeNull ( ) ;
219246 result . MaxIdleTime . Should ( ) . Be ( subject . MaxIdleTime ) ;
220247 result . MaxLifeTime . Should ( ) . Be ( subject . MaxLifeTime ) ;
@@ -232,6 +259,7 @@ public void With_libraryInfo_should_return_expected_result()
232259 result . ApplicationName . Should ( ) . Be ( subject . ApplicationName ) ;
233260 result . AuthenticatorFactory . Should ( ) . Be ( subject . AuthenticatorFactory ) ;
234261 result . Compressors . Should ( ) . Equal ( __defaults . Compressors ) ;
262+ result . ConnectionIdLocalValueProvider . Should ( ) . Be ( subject . ConnectionIdLocalValueProvider ) ;
235263 result . LibraryInfo . Should ( ) . Be ( newlibraryInfo ) ;
236264 result . MaxIdleTime . Should ( ) . Be ( subject . MaxIdleTime ) ;
237265 result . MaxLifeTime . Should ( ) . Be ( subject . MaxLifeTime ) ;
@@ -249,6 +277,7 @@ public void With_maxIdleTime_should_return_expected_result()
249277 result . ApplicationName . Should ( ) . Be ( subject . ApplicationName ) ;
250278 result . AuthenticatorFactory . Should ( ) . Be ( subject . AuthenticatorFactory ) ;
251279 result . Compressors . Should ( ) . Equal ( subject . Compressors ) ;
280+ result . ConnectionIdLocalValueProvider . Should ( ) . Be ( subject . ConnectionIdLocalValueProvider ) ;
252281 result . LibraryInfo . Should ( ) . BeNull ( ) ;
253282 result . MaxIdleTime . Should ( ) . Be ( newMaxIdleTime ) ;
254283 result . MaxLifeTime . Should ( ) . Be ( subject . MaxLifeTime ) ;
@@ -266,6 +295,7 @@ public void With_maxLifeTime_should_return_expected_result()
266295 result . ApplicationName . Should ( ) . Be ( subject . ApplicationName ) ;
267296 result . AuthenticatorFactory . Should ( ) . Be ( subject . AuthenticatorFactory ) ;
268297 result . Compressors . Should ( ) . Equal ( subject . Compressors ) ;
298+ result . ConnectionIdLocalValueProvider . Should ( ) . Be ( subject . ConnectionIdLocalValueProvider ) ;
269299 result . LibraryInfo . Should ( ) . BeNull ( ) ;
270300 result . MaxIdleTime . Should ( ) . Be ( subject . MaxIdleTime ) ;
271301 result . MaxLifeTime . Should ( ) . Be ( newMaxLifeTime ) ;
0 commit comments