11using Oracle . ManagedDataAccess . Client ;
22using System ;
3+ using System . Collections . Generic ;
34using System . Data ;
4- using System . Diagnostics ;
55using System . IO ;
66using System . Xml . Serialization ;
77
@@ -12,41 +12,35 @@ namespace utPLSQL
1212 /// </summary>
1313 public class RealTimeTestRunner : TestRunner < @event >
1414 {
15- public override void RunTests ( Type type , string owner , string name , string procedure )
15+ public override void RunTests ( List < string > paths )
1616 {
17- var testsToRun = GetTestsToRun ( type , owner , name , procedure ) ;
18-
19- if ( testsToRun != null )
17+ if ( paths != null && paths . Count > 0 )
2018 {
2119 realtimeReporterId = Guid . NewGuid ( ) . ToString ( ) . Replace ( "-" , "" ) ;
2220
23- var proc = @"DECLARE
21+ var proc = $ @ "DECLARE
2422 l_reporter ut_realtime_reporter := ut_realtime_reporter();
2523 BEGIN
2624 l_reporter.set_reporter_id(:id);
2725 l_reporter.output_buffer.init();
28- ut_runner.run(a_paths => ut_varchar2_list(:test), a_reporters => ut_reporters(l_reporter));
26+ ut_runner.run(a_paths => ut_varchar2_list({ ConvertToUtVarchar2List ( paths ) } ),
27+ a_reporters => ut_reporters(l_reporter));
2928 END;" ;
3029
3130 var cmd = new OracleCommand ( proc , produceConnection ) ;
3231 cmd . Parameters . Add ( "id" , OracleDbType . Varchar2 , ParameterDirection . Input ) . Value = realtimeReporterId ;
33- cmd . Parameters . Add ( "test" , OracleDbType . Varchar2 , ParameterDirection . Input ) . Value = testsToRun ;
3432 cmd . ExecuteNonQuery ( ) ;
3533 }
3634 }
3735
38-
39- public override void RunTestsWithCoverage ( Type type , string owner , string name , string procedure , string coverageSchemas ,
40- string includeObjects , string excludeObjects )
36+ public override void RunTestsWithCoverage ( List < string > paths , List < string > coverageSchemas , List < string > includeObjects , List < string > excludeObjects )
4137 {
42- var testsToRun = GetTestsToRun ( type , owner , name , procedure ) ;
43-
44- if ( testsToRun != null )
38+ if ( paths != null && paths . Count > 0 )
4539 {
4640 realtimeReporterId = Guid . NewGuid ( ) . ToString ( ) . Replace ( "-" , "" ) ;
4741 coverageReporterId = Guid . NewGuid ( ) . ToString ( ) . Replace ( "-" , "" ) ;
4842
49- var proc = @"DECLARE
43+ var proc = $ @ "DECLARE
5044 l_rt_rep ut_realtime_reporter := ut_realtime_reporter();
5145 l_cov_rep ut_coverage_html_reporter := ut_coverage_html_reporter();
5246 BEGIN
@@ -55,21 +49,21 @@ public override void RunTestsWithCoverage(Type type, string owner, string name,
5549 l_cov_rep.set_reporter_id(:coverage_id);
5650 l_cov_rep.output_buffer.init();
5751 sys.dbms_output.enable(NULL);
58- ut_runner.run(a_paths => ut_varchar2_list(:test ), " ;
52+ ut_runner.run(a_paths => ut_varchar2_list({ ConvertToUtVarchar2List ( paths ) } ), " ;
5953
60- if ( ! string . IsNullOrWhiteSpace ( coverageSchemas ) )
54+ if ( coverageSchemas != null && coverageSchemas . Count > 0 )
6155 {
62- proc += $ "a_coverage_schemes => ut_varchar2_list({ coverageSchemas } ), ";
56+ proc += $ "a_coverage_schemes => ut_varchar2_list({ ConvertToUtVarchar2List ( coverageSchemas ) } ), ";
6357 }
6458
65- if ( ! string . IsNullOrWhiteSpace ( includeObjects ) )
59+ if ( includeObjects != null && includeObjects . Count > 0 )
6660 {
67- proc += $ "a_include_objects => ut_varchar2_list({ includeObjects } ), ";
61+ proc += $ "a_include_objects => ut_varchar2_list({ ConvertToUtVarchar2List ( includeObjects ) } ), ";
6862 }
6963
70- if ( ! string . IsNullOrWhiteSpace ( excludeObjects ) )
64+ if ( excludeObjects != null && excludeObjects . Count > 0 )
7165 {
72- proc += $ "a_exclude_objects => ut_varchar2_list({ excludeObjects } ), ";
66+ proc += $ "a_exclude_objects => ut_varchar2_list({ ConvertToUtVarchar2List ( excludeObjects ) } ), ";
7367 }
7468
7569 proc += @" a_reporters => ut_reporters(l_rt_rep, l_cov_rep));
@@ -79,19 +73,8 @@ public override void RunTestsWithCoverage(Type type, string owner, string name,
7973 var cmd = new OracleCommand ( proc , produceConnection ) ;
8074 cmd . Parameters . Add ( "id" , OracleDbType . Varchar2 , ParameterDirection . Input ) . Value = realtimeReporterId ;
8175 cmd . Parameters . Add ( "coverage_id" , OracleDbType . Varchar2 , ParameterDirection . Input ) . Value = coverageReporterId ;
82- cmd . Parameters . Add ( "test" , OracleDbType . Varchar2 , ParameterDirection . Input ) . Value = testsToRun ;
8376
84- try
85- {
86- cmd . ExecuteNonQuery ( ) ;
87- }
88- catch ( Exception e )
89- {
90- using ( var eventLog = new EventLog ( "Application" ) )
91- {
92- eventLog . WriteEntry ( $ "{ e . Message } { e . StackTrace } ", EventLogEntryType . Error , 0 ) ;
93- }
94- }
77+ cmd . ExecuteNonQuery ( ) ;
9578 }
9679 }
9780
@@ -124,28 +107,5 @@ public override void ConsumeResult(Action<@event> action)
124107
125108 reader . Close ( ) ;
126109 }
127-
128- private static string GetTestsToRun ( Type type , string owner , string name , string procedure )
129- {
130- string testsToRun = null ;
131-
132- switch ( type )
133- {
134- case Type . User :
135- testsToRun = name ;
136- break ;
137- case Type . Package :
138- testsToRun = $ "{ owner } .{ name } ";
139- break ;
140- case Type . Procedure :
141- testsToRun = $ "{ owner } .{ name } .{ procedure } ";
142- break ;
143- case Type . All :
144- testsToRun = owner ;
145- break ;
146- }
147-
148- return testsToRun ;
149- }
150110 }
151111}
0 commit comments