File tree Expand file tree Collapse file tree 2 files changed +28
-29
lines changed Expand file tree Collapse file tree 2 files changed +28
-29
lines changed Original file line number Diff line number Diff line change @@ -62,6 +62,34 @@ public async Task UnpooledConnectionIsClosed()
62
62
}
63
63
}
64
64
65
+ [ Theory ]
66
+ [ InlineData ( 2u , 3u , true ) ]
67
+ [ InlineData ( 180u , 3u , false ) ]
68
+ public async Task ConnectionLifeTime ( uint lifeTime , uint delaySeconds , bool shouldTimeout )
69
+ {
70
+ m_csb . Pooling = true ;
71
+ m_csb . MinimumPoolSize = 0 ;
72
+ m_csb . MaximumPoolSize = 1 ;
73
+ m_csb . ConnectionLifeTime = lifeTime ;
74
+ int serverThread ;
75
+
76
+ using ( var connection = new MySqlConnection ( m_csb . ConnectionString ) )
77
+ {
78
+ await connection . OpenAsync ( ) ;
79
+ serverThread = connection . ServerThread ;
80
+ await Task . Delay ( TimeSpan . FromSeconds ( delaySeconds ) ) ;
81
+ }
82
+
83
+ using ( var connection = new MySqlConnection ( m_csb . ConnectionString ) )
84
+ {
85
+ await connection . OpenAsync ( ) ;
86
+ if ( shouldTimeout )
87
+ Assert . NotEqual ( serverThread , connection . ServerThread ) ;
88
+ else
89
+ Assert . Equal ( serverThread , connection . ServerThread ) ;
90
+ }
91
+ }
92
+
65
93
private static async Task WaitForConditionAsync < T > ( T expected , Func < T > getValue )
66
94
{
67
95
var sw = Stopwatch . StartNew ( ) ;
Original file line number Diff line number Diff line change @@ -205,35 +205,6 @@ public async Task WaitTimeout()
205
205
}
206
206
}
207
207
208
- [ Theory ]
209
- [ InlineData ( 2u , 3u , true ) ]
210
- [ InlineData ( 180u , 3u , false ) ]
211
- public async Task ConnectionLifeTime ( uint lifeTime , uint delaySeconds , bool shouldTimeout )
212
- {
213
- var csb = AppConfig . CreateConnectionStringBuilder ( ) ;
214
- csb . Pooling = true ;
215
- csb . MinimumPoolSize = 0 ;
216
- csb . MaximumPoolSize = 1 ;
217
- csb . ConnectionLifeTime = lifeTime ;
218
- int serverThread ;
219
-
220
- using ( var connection = new MySqlConnection ( csb . ConnectionString ) )
221
- {
222
- await connection . OpenAsync ( ) ;
223
- serverThread = connection . ServerThread ;
224
- await Task . Delay ( TimeSpan . FromSeconds ( delaySeconds ) ) ;
225
- }
226
-
227
- using ( var connection = new MySqlConnection ( csb . ConnectionString ) )
228
- {
229
- await connection . OpenAsync ( ) ;
230
- if ( shouldTimeout )
231
- Assert . NotEqual ( serverThread , connection . ServerThread ) ;
232
- else
233
- Assert . Equal ( serverThread , connection . ServerThread ) ;
234
- }
235
- }
236
-
237
208
[ Fact ]
238
209
public async Task CharacterSet ( )
239
210
{
You can’t perform that action at this time.
0 commit comments