Skip to content

Commit 3cc391a

Browse files
committed
Merge branch 'release/1.3.0' into main
2 parents 1479a7f + cc7d175 commit 3cc391a

File tree

7 files changed

+75
-87
lines changed

7 files changed

+75
-87
lines changed

README.md

+5-4
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
testRunner.Connect(username: "toscamtest", password: "toscamtest", database: "CA40");
1010

1111
// Runs tests for the user tosamtest
12-
testRunner.RunTests(type: Type.User, owner: null, name: "toscamtest", procedure: null);
12+
testRunner.RunTests(paths: new List<string>() { "toscamtest" });
1313

1414
var events = new List<@event>();
1515
testRunner.ConsumeResult(@event =>
@@ -22,9 +22,10 @@
2222
var testRunner = new RealTimeTestRunner();
2323
testRunner.Connect(username: "toscamtest", password: "toscamtest", database: "CA40");
2424

25-
// Runs tests for the user tosamtest
26-
testRunner.RunTestsWithCoverage(type: Type.User, owner: null, name: "toscamtest", procedure: null,
27-
coverageSchemas: "'toscam'", includeObjects: "'pa_m720','pa_m770'",
25+
// Runs tests for the user tosamtest with coverage
26+
testRunner.RunTestsWithCoverage(paths: new List<string>() { "toscamtest" },
27+
coverageSchemas: new List<string>() { "toscam" },
28+
includeObjects: new List<string>() { "pa_m720", "pa_m770" },
2829
excludeObjects: null);
2930

3031
var events = new List<@event>();

utPLSQL.Api/utPLSQL.Api.Test/Properties/AssemblyInfo.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,5 @@
1616
[assembly: Guid("0da0b937-f3fe-4fdf-8e34-716497a14823")]
1717

1818
// [assembly: AssemblyVersion("1.0.*")]
19-
[assembly: AssemblyVersion("1.0.0.0")]
20-
[assembly: AssemblyFileVersion("1.0.0.0")]
19+
[assembly: AssemblyVersion("1.3.0.0")]
20+
[assembly: AssemblyFileVersion("1.3.0.0")]

utPLSQL.Api/utPLSQL.Api.Test/RealTimeTestRunnerTest.cs

+23-2
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,33 @@ namespace utPLSQL
99
public class RealTimeTestRunnerTest
1010
{
1111
[TestMethod]
12-
public void TestToscamtest()
12+
public void TestRunTests()
1313
{
1414
var testRunner = new RealTimeTestRunner();
1515
testRunner.Connect(username: "toscamtest", password: "toscamtest", database: "CA40");
1616

17-
testRunner.RunTestsWithCoverage(type: Type.User, owner: null, name: "toscamtest", procedure: null, coverageSchemas: "'toscam'", "'pa_m720','pa_m770'", null);
17+
testRunner.RunTests(paths: new List<string>() { "toscamtest" });
18+
19+
var events = new List<@event>();
20+
testRunner.ConsumeResult(@event =>
21+
{
22+
events.Add(@event);
23+
});
24+
25+
Assert.AreEqual("pre-run", events[0].type);
26+
Assert.AreEqual("post-run", events.Last().type);
27+
}
28+
29+
[TestMethod]
30+
public void TestRunTestsWithCoverage()
31+
{
32+
var testRunner = new RealTimeTestRunner();
33+
testRunner.Connect(username: "toscamtest", password: "toscamtest", database: "CA40");
34+
35+
testRunner.RunTestsWithCoverage(paths: new List<string>() { "toscamtest" },
36+
coverageSchemas: new List<string>() { "toscam" },
37+
includeObjects: new List<string>() { "pa_m720", "pa_m770" },
38+
excludeObjects: null);
1839

1940
var events = new List<@event>();
2041
testRunner.ConsumeResult(@event =>

utPLSQL.Api/utPLSQL.Api/Properties/AssemblyInfo.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -32,5 +32,5 @@
3232
// You can specify all the values or you can default the Build and Revision Numbers
3333
// by using the '*' as shown below:
3434
// [assembly: AssemblyVersion("1.0.*")]
35-
[assembly: AssemblyVersion("1.2.0.0")]
36-
[assembly: AssemblyFileVersion("1.2.0.0")]
35+
[assembly: AssemblyVersion("1.3.0.0")]
36+
[assembly: AssemblyFileVersion("1.3.0.0")]
+17-57
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
using Oracle.ManagedDataAccess.Client;
22
using System;
3+
using System.Collections.Generic;
34
using System.Data;
4-
using System.Diagnostics;
55
using System.IO;
66
using 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
}

utPLSQL.Api/utPLSQL.Api/TestRunner.cs

+24-18
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
using Oracle.ManagedDataAccess.Client;
22
using System;
3+
using System.Collections.Generic;
34
using System.Data;
45
using System.Text;
56

@@ -60,24 +61,17 @@ public String GetVersion()
6061
/// <summary>
6162
/// Run tests
6263
/// </summary>
63-
/// <param name="type">The type to use</param>
64-
/// <param name="owner">Owner of the object</param>
65-
/// <param name="name">Name of the object</param>
66-
/// <param name="procedure">Procedure name</param>
67-
public abstract void RunTests(Type type, string owner, string name, string procedure);
64+
/// <param name="paths">List of path expressions</param>
65+
public abstract void RunTests(List<string> paths);
6866

6967
/// <summary>
7068
/// Run tests with coveage
7169
/// </summary>
72-
/// <param name="type">The type to use</param>
73-
/// <param name="owner">Owner of the object</param>
74-
/// <param name="name">Name of the object</param>
75-
/// <param name="procedure">Procedure name</param>
76-
/// <param name="coverageSchemas">Schemas to cover</param>
77-
/// <param name="includeObjects">Objects to include</param>
78-
/// <param name="excludeObjects">Objects to exclude</param>
79-
public abstract void RunTestsWithCoverage(Type type, string owner, string name, string procedure, string coverageSchemas,
80-
string includeObjects, string excludeObjects);
70+
/// <param name="paths">List of path expressions</param>
71+
/// <param name="coverageSchemas">List of schemas to cover</param>
72+
/// <param name="includeObjects">List of objects to include</param>
73+
/// <param name="excludeObjects">List of objects to exclude</param>
74+
public abstract void RunTestsWithCoverage(List<string> paths, List<string> coverageSchemas, List<string> includeObjects, List<string> excludeObjects);
8175

8276
/// <summary>
8377
/// Consumes the results and calls the callback action on each result
@@ -119,9 +113,21 @@ public string GetCoverageReport()
119113

120114
return sb.ToString();
121115
}
122-
}
123-
public enum Type
124-
{
125-
User, Package, Procedure, All
116+
117+
protected string ConvertToUtVarchar2List(List<string> elements)
118+
{
119+
var sb = new StringBuilder();
120+
bool first = true;
121+
foreach (var element in elements)
122+
{
123+
if (!first)
124+
{
125+
sb.Append(",");
126+
}
127+
sb.Append("'").Append(element).Append("'");
128+
first = false;
129+
}
130+
return sb.ToString();
131+
}
126132
}
127133
}

utPLSQL.Api/utPLSQL.Api/utPLSQL.Api.nuspec

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,15 @@
22
<package >
33
<metadata>
44
<id>utPLSQL.Api</id>
5-
<version>1.2.1</version>
5+
<version>1.3.0</version>
66
<title>utPLSQL API</title>
77
<authors>Simon Martinelli</authors>
88
<requireLicenseAcceptance>false</requireLicenseAcceptance>
99
<license type="expression">Apache-2.0+</license>
1010
<projectUrl>https://github.com/utPLSQL/utPLSQL-dotnet-api</projectUrl>
1111
<icon>images/blue-icon-transparent.png</icon>
1212
<description>.NET API for utPLSQL</description>
13-
<releaseNotes>Changed type to enum</releaseNotes>
13+
<releaseNotes>Changed from fields to paths as one parameter</releaseNotes>
1414
<copyright>Copyright © 2021</copyright>
1515
<tags>utPLSQL</tags>
1616
</metadata>

0 commit comments

Comments
 (0)