@@ -18,6 +18,8 @@ public abstract class TestRunner<T>
1818 protected string realtimeReporterId ;
1919 protected string coverageReporterId ;
2020
21+ protected List < OracleCommand > runningCommands = new List < OracleCommand > ( ) ;
22+
2123 /// <summary>
2224 /// Connects to the database.
2325 /// The TestRunner uses two connections. One for executing the tests and one for consuming the results
@@ -29,6 +31,11 @@ public void Connect(string username, string password, string database)
2931 {
3032 var connectionString = $ "User Id={ username } ;Password={ password } ;Data Source={ database } ";
3133
34+ foreach ( OracleCommand command in runningCommands )
35+ {
36+ command . Cancel ( ) ;
37+ }
38+
3239 produceConnection = new OracleConnection ( connectionString ) ;
3340 produceConnection . Open ( ) ;
3441
@@ -51,12 +58,16 @@ public void Close()
5158 public String GetVersion ( )
5259 {
5360 var cmd = new OracleCommand ( "select ut.version() from dual" , produceConnection ) ;
61+ runningCommands . Add ( cmd ) ;
62+
5463 OracleDataReader reader = cmd . ExecuteReader ( ) ;
5564 reader . Read ( ) ;
5665
5766 var version = reader . GetString ( 0 ) ;
5867
5968 reader . Close ( ) ;
69+
70+ runningCommands . Remove ( cmd ) ;
6071 cmd . Dispose ( ) ;
6172
6273 return version ;
@@ -108,6 +119,8 @@ public string GetCoverageReport()
108119 END;" ;
109120
110121 var cmd = new OracleCommand ( proc , consumeConnection ) ;
122+ runningCommands . Add ( cmd ) ;
123+
111124 cmd . Parameters . Add ( "id" , OracleDbType . Varchar2 , ParameterDirection . Input ) . Value = coverageReporterId ;
112125 cmd . Parameters . Add ( "lines_cursor" , OracleDbType . RefCursor , ParameterDirection . Output ) ;
113126
@@ -123,6 +136,8 @@ public string GetCoverageReport()
123136 }
124137
125138 reader . Close ( ) ;
139+
140+ runningCommands . Remove ( cmd ) ;
126141 cmd . Dispose ( ) ;
127142
128143 return sb . ToString ( ) ;
0 commit comments