@@ -26,73 +26,74 @@ public class FirebirdClientDriverFixtureAsync
2626 private string _connectionString ;
2727 private FirebirdClientDriver _driver ;
2828
29+ [ OneTimeSetUp ]
30+ public void OneTimeSetup ( )
31+ {
32+ var cfg = TestConfigurationHelper . GetDefaultConfiguration ( ) ;
33+
34+ var dlct = cfg . GetProperty ( "dialect" ) ;
35+ if ( ! dlct . Contains ( "Firebird" ) )
36+ Assert . Ignore ( "Applies only to Firebird" ) ;
37+
38+ _driver = new FirebirdClientDriver ( ) ;
39+ _driver . Configure ( cfg . Properties ) ;
40+ _connectionString = cfg . GetProperty ( "connection.connection_string" ) ;
41+ }
42+
2943 [ Test ]
3044 public async Task ConnectionPooling_OpenThenCloseThenOpenAnotherOne_OnlyOneConnectionIsPooledAsync ( )
3145 {
32- MakeDriver ( ) ;
33-
3446 _driver . ClearPool ( _connectionString ) ;
3547
3648 var allreadyEstablished = await ( GetEstablishedConnectionsAsync ( ) ) ;
3749
38- var connection1 = MakeConnection ( ) ;
39- var connection2 = MakeConnection ( ) ;
40-
41- //open first connection
42- await ( connection1 . OpenAsync ( ) ) ;
43- await ( VerifyCountOfEstablishedConnectionsIsAsync ( allreadyEstablished + 1 , "After first open" ) ) ;
50+ using ( var connection1 = MakeConnection ( ) )
51+ using ( var connection2 = MakeConnection ( ) )
52+ {
53+ //open first connection
54+ await ( connection1 . OpenAsync ( ) ) ;
55+ await ( VerifyCountOfEstablishedConnectionsIsAsync ( allreadyEstablished + 1 , "After first open" ) ) ;
4456
45- //return it to the pool
46- connection1 . Close ( ) ;
47- await ( VerifyCountOfEstablishedConnectionsIsAsync ( allreadyEstablished + 1 , "After first close" ) ) ;
57+ //return it to the pool
58+ connection1 . Close ( ) ;
59+ await ( VerifyCountOfEstablishedConnectionsIsAsync ( allreadyEstablished + 1 , "After first close" ) ) ;
4860
49- //open the second connection
50- await ( connection2 . OpenAsync ( ) ) ;
51- await ( VerifyCountOfEstablishedConnectionsIsAsync ( allreadyEstablished + 1 , "After second open" ) ) ;
61+ //open the second connection
62+ await ( connection2 . OpenAsync ( ) ) ;
63+ await ( VerifyCountOfEstablishedConnectionsIsAsync ( allreadyEstablished + 1 , "After second open" ) ) ;
5264
53- //return it to the pool
54- connection2 . Close ( ) ;
55- await ( VerifyCountOfEstablishedConnectionsIsAsync ( allreadyEstablished + 1 , "After second close" ) ) ;
65+ //return it to the pool
66+ connection2 . Close ( ) ;
67+ await ( VerifyCountOfEstablishedConnectionsIsAsync ( allreadyEstablished + 1 , "After second close" ) ) ;
68+ }
5669 }
5770
5871 [ Test ]
5972 public async Task ConnectionPooling_OpenThenCloseTwoAtTheSameTime_TowConnectionsArePooledAsync ( )
6073 {
61- MakeDriver ( ) ;
62-
6374 _driver . ClearPool ( _connectionString ) ;
6475
6576 var allreadyEstablished = await ( GetEstablishedConnectionsAsync ( ) ) ;
6677
67- var connection1 = MakeConnection ( ) ;
68- var connection2 = MakeConnection ( ) ;
69-
70- //open first connection
71- await ( connection1 . OpenAsync ( ) ) ;
72- await ( VerifyCountOfEstablishedConnectionsIsAsync ( allreadyEstablished + 1 , "After first open" ) ) ;
73-
74- //open second one
75- await ( connection2 . OpenAsync ( ) ) ;
76- await ( VerifyCountOfEstablishedConnectionsIsAsync ( allreadyEstablished + 2 , "After second open" ) ) ;
77-
78- //return connection1 to the pool
79- connection1 . Close ( ) ;
80- await ( VerifyCountOfEstablishedConnectionsIsAsync ( allreadyEstablished + 2 , "After first close" ) ) ;
78+ using ( var connection1 = MakeConnection ( ) )
79+ using ( var connection2 = MakeConnection ( ) )
80+ {
81+ //open first connection
82+ await ( connection1 . OpenAsync ( ) ) ;
83+ await ( VerifyCountOfEstablishedConnectionsIsAsync ( allreadyEstablished + 1 , "After first open" ) ) ;
8184
82- //return connection2 to the pool
83- connection2 . Close ( ) ;
84- await ( VerifyCountOfEstablishedConnectionsIsAsync ( allreadyEstablished + 2 , "After second close" ) ) ;
85- }
85+ //open second one
86+ await ( connection2 . OpenAsync ( ) ) ;
87+ await ( VerifyCountOfEstablishedConnectionsIsAsync ( allreadyEstablished + 2 , "After second open" ) ) ;
8688
87- private void MakeDriver ( )
88- {
89- var cfg = TestConfigurationHelper . GetDefaultConfiguration ( ) ;
90- var dlct = cfg . GetProperty ( "dialect" ) ;
91- if ( ! dlct . Contains ( "Firebird" ) )
92- Assert . Ignore ( "Applies only to Firebird" ) ;
89+ //return connection1 to the pool
90+ connection1 . Close ( ) ;
91+ await ( VerifyCountOfEstablishedConnectionsIsAsync ( allreadyEstablished + 2 , "After first close" ) ) ;
9392
94- _driver = new FirebirdClientDriver ( ) ;
95- _connectionString = cfg . GetProperty ( "connection.connection_string" ) ;
93+ //return connection2 to the pool
94+ connection2 . Close ( ) ;
95+ await ( VerifyCountOfEstablishedConnectionsIsAsync ( allreadyEstablished + 2 , "After second close" ) ) ;
96+ }
9697 }
9798
9899 private DbConnection MakeConnection ( )
@@ -125,38 +126,38 @@ private DbConnection MakeConnection()
125126 private DbCommand BuildSelectCaseCommand ( SqlType paramType )
126127 {
127128 var sqlString = new SqlStringBuilder ( )
128- . Add ( "select (case when col = " )
129- . AddParameter ( )
130- . Add ( " then " )
131- . AddParameter ( )
132- . Add ( " else " )
133- . AddParameter ( )
134- . Add ( " end) from table" )
135- . ToSqlString ( ) ;
129+ . Add ( "select (case when col = " )
130+ . AddParameter ( )
131+ . Add ( " then " )
132+ . AddParameter ( )
133+ . Add ( " else " )
134+ . AddParameter ( )
135+ . Add ( " end) from table" )
136+ . ToSqlString ( ) ;
136137
137138 return _driver . GenerateCommand ( CommandType . Text , sqlString , new [ ] { paramType , paramType , paramType } ) ;
138139 }
139140
140141 private DbCommand BuildSelectConcatCommand ( SqlType paramType )
141142 {
142143 var sqlString = new SqlStringBuilder ( )
143- . Add ( "select col || " )
144- . AddParameter ( )
145- . Add ( " || " )
146- . Add ( "col " )
147- . Add ( "from table" )
148- . ToSqlString ( ) ;
144+ . Add ( "select col || " )
145+ . AddParameter ( )
146+ . Add ( " || " )
147+ . Add ( "col " )
148+ . Add ( "from table" )
149+ . ToSqlString ( ) ;
149150
150151 return _driver . GenerateCommand ( CommandType . Text , sqlString , new [ ] { paramType } ) ;
151152 }
152153
153154 private DbCommand BuildSelectAddCommand ( SqlType paramType )
154155 {
155156 var sqlString = new SqlStringBuilder ( )
156- . Add ( "select col + " )
157- . AddParameter ( )
158- . Add ( " from table" )
159- . ToSqlString ( ) ;
157+ . Add ( "select col + " )
158+ . AddParameter ( )
159+ . Add ( " from table" )
160+ . ToSqlString ( ) ;
160161
161162 return _driver . GenerateCommand ( CommandType . Text , sqlString , new [ ] { paramType } ) ;
162163 }
@@ -172,6 +173,7 @@ private DbCommand BuildInsertWithParamsInSelectCommand(SqlType paramType)
172173
173174 return _driver . GenerateCommand ( CommandType . Text , sqlString , new [ ] { paramType } ) ;
174175 }
176+
175177 private DbCommand BuildInsertWithParamsInSelectCommandWithSelectInColumnName ( SqlType paramType )
176178 {
177179 var sqlString = new SqlStringBuilder ( )
@@ -184,7 +186,7 @@ private DbCommand BuildInsertWithParamsInSelectCommandWithSelectInColumnName(Sql
184186 return _driver . GenerateCommand ( CommandType . Text , sqlString , new [ ] { paramType } ) ;
185187 }
186188
187- private DbCommand BuildInsertWithParamsInSelectCommandWithWhereInColumnName ( SqlType paramType )
189+ private DbCommand BuildInsertWithParamsInSelectCommandWithWhereInColumnName ( SqlType paramType )
188190 {
189191 var sqlString = new SqlStringBuilder ( )
190192 . Add ( "insert into table1 (col1_where_aaa) " )
0 commit comments