1
1
using Oracle . ManagedDataAccess . Client ;
2
2
using System ;
3
+ using System . Collections . Generic ;
3
4
using System . Data ;
4
- using System . Diagnostics ;
5
5
using System . IO ;
6
6
using System . Xml . Serialization ;
7
7
@@ -12,41 +12,35 @@ namespace utPLSQL
12
12
/// </summary>
13
13
public class RealTimeTestRunner : TestRunner < @event >
14
14
{
15
- public override void RunTests ( Type type , string owner , string name , string procedure )
15
+ public override void RunTests ( List < string > paths )
16
16
{
17
- var testsToRun = GetTestsToRun ( type , owner , name , procedure ) ;
18
-
19
- if ( testsToRun != null )
17
+ if ( paths != null && paths . Count > 0 )
20
18
{
21
19
realtimeReporterId = Guid . NewGuid ( ) . ToString ( ) . Replace ( "-" , "" ) ;
22
20
23
- var proc = @"DECLARE
21
+ var proc = $ @ "DECLARE
24
22
l_reporter ut_realtime_reporter := ut_realtime_reporter();
25
23
BEGIN
26
24
l_reporter.set_reporter_id(:id);
27
25
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));
29
28
END;" ;
30
29
31
30
var cmd = new OracleCommand ( proc , produceConnection ) ;
32
31
cmd . Parameters . Add ( "id" , OracleDbType . Varchar2 , ParameterDirection . Input ) . Value = realtimeReporterId ;
33
- cmd . Parameters . Add ( "test" , OracleDbType . Varchar2 , ParameterDirection . Input ) . Value = testsToRun ;
34
32
cmd . ExecuteNonQuery ( ) ;
35
33
}
36
34
}
37
35
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 )
41
37
{
42
- var testsToRun = GetTestsToRun ( type , owner , name , procedure ) ;
43
-
44
- if ( testsToRun != null )
38
+ if ( paths != null && paths . Count > 0 )
45
39
{
46
40
realtimeReporterId = Guid . NewGuid ( ) . ToString ( ) . Replace ( "-" , "" ) ;
47
41
coverageReporterId = Guid . NewGuid ( ) . ToString ( ) . Replace ( "-" , "" ) ;
48
42
49
- var proc = @"DECLARE
43
+ var proc = $ @ "DECLARE
50
44
l_rt_rep ut_realtime_reporter := ut_realtime_reporter();
51
45
l_cov_rep ut_coverage_html_reporter := ut_coverage_html_reporter();
52
46
BEGIN
@@ -55,21 +49,21 @@ public override void RunTestsWithCoverage(Type type, string owner, string name,
55
49
l_cov_rep.set_reporter_id(:coverage_id);
56
50
l_cov_rep.output_buffer.init();
57
51
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 ) } ), " ;
59
53
60
- if ( ! string . IsNullOrWhiteSpace ( coverageSchemas ) )
54
+ if ( coverageSchemas != null && coverageSchemas . Count > 0 )
61
55
{
62
- proc += $ "a_coverage_schemes => ut_varchar2_list({ coverageSchemas } ), ";
56
+ proc += $ "a_coverage_schemes => ut_varchar2_list({ ConvertToUtVarchar2List ( coverageSchemas ) } ), ";
63
57
}
64
58
65
- if ( ! string . IsNullOrWhiteSpace ( includeObjects ) )
59
+ if ( includeObjects != null && includeObjects . Count > 0 )
66
60
{
67
- proc += $ "a_include_objects => ut_varchar2_list({ includeObjects } ), ";
61
+ proc += $ "a_include_objects => ut_varchar2_list({ ConvertToUtVarchar2List ( includeObjects ) } ), ";
68
62
}
69
63
70
- if ( ! string . IsNullOrWhiteSpace ( excludeObjects ) )
64
+ if ( excludeObjects != null && excludeObjects . Count > 0 )
71
65
{
72
- proc += $ "a_exclude_objects => ut_varchar2_list({ excludeObjects } ), ";
66
+ proc += $ "a_exclude_objects => ut_varchar2_list({ ConvertToUtVarchar2List ( excludeObjects ) } ), ";
73
67
}
74
68
75
69
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,
79
73
var cmd = new OracleCommand ( proc , produceConnection ) ;
80
74
cmd . Parameters . Add ( "id" , OracleDbType . Varchar2 , ParameterDirection . Input ) . Value = realtimeReporterId ;
81
75
cmd . Parameters . Add ( "coverage_id" , OracleDbType . Varchar2 , ParameterDirection . Input ) . Value = coverageReporterId ;
82
- cmd . Parameters . Add ( "test" , OracleDbType . Varchar2 , ParameterDirection . Input ) . Value = testsToRun ;
83
76
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 ( ) ;
95
78
}
96
79
}
97
80
@@ -124,28 +107,5 @@ public override void ConsumeResult(Action<@event> action)
124
107
125
108
reader . Close ( ) ;
126
109
}
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
- }
150
110
}
151
111
}
0 commit comments