Skip to content

Commit fbff6ee

Browse files
committed
Merge branch 'release/1.5.4' into main
2 parents ff2ebe4 + 4ee9518 commit fbff6ee

File tree

8 files changed

+88
-43
lines changed

8 files changed

+88
-43
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,6 @@
33
**/packages
44
**/**/bin
55
**/**/obj
6-
/.idea/
6+
**/.idea/
77
**/**/*.nupkg
8+
**/utPLSQL.Api.sln.DotSettings.user

utPLSQL.Api/SetAssemblyVersion.ps1

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
param([string]$NewVersion)
2+
3+
Get-ChildItem -Include AssemblyInfo.cs -Recurse | ForEach-Object {
4+
$_.IsReadOnly = $false
5+
(Get-Content -Path $_) -replace '(?<=Assembly(?:File)?Version\(")[^"]*(?="\))', $NewVersion |Set-Content -Path $_
6+
}

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

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22
using System.Runtime.CompilerServices;
33
using System.Runtime.InteropServices;
44

5+
// General Information about an assembly is controlled through the following
6+
// set of attributes. Change these attribute values to modify the information
7+
// associated with an assembly.
58
[assembly: AssemblyTitle("utPLSQL.Api.Test")]
69
[assembly: AssemblyDescription("")]
710
[assembly: AssemblyConfiguration("")]
@@ -11,10 +14,20 @@
1114
[assembly: AssemblyTrademark("")]
1215
[assembly: AssemblyCulture("")]
1316

17+
// Setting ComVisible to false makes the types in this assembly not visible
18+
// to COM components. If you need to access a type in this assembly from
19+
// COM, set the ComVisible attribute to true on that type.
1420
[assembly: ComVisible(false)]
1521

22+
// The following GUID is for the ID of the typelib if this project is exposed to COM
1623
[assembly: Guid("0da0b937-f3fe-4fdf-8e34-716497a14823")]
1724

18-
// [assembly: AssemblyVersion("1.0.*")]
19-
[assembly: AssemblyVersion("1.3.0.0")]
20-
[assembly: AssemblyFileVersion("1.3.0.0")]
25+
// Version information for an assembly consists of the following four values:
26+
//
27+
// Major Version
28+
// Minor Version
29+
// Build Number
30+
// Revision
31+
//
32+
[assembly: AssemblyVersion("1.5.4.0")]
33+
[assembly: AssemblyFileVersion("1.5.4.0")]

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

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,16 @@ namespace utPLSQL
1010
[TestClass]
1111
public class RealTimeTestRunnerTest
1212
{
13+
const string username = "ut3_tester";
14+
const string password = "ut3";
15+
const string database = "xepdb1";
1316

1417
[TestMethod]
1518
public async Task TestRunTests()
1619
{
1720
var testRunner = new RealTimeTestRunner();
1821

19-
testRunner.Connect(username: "ut3_tester", password: "ut3", database: "orclpdb1");
22+
testRunner.Connect(username, password, database);
2023

2124
var events = new List<@event>();
2225
await testRunner.RunTestsAsync("ut3_tester.test_ut_test", @event =>
@@ -35,7 +38,7 @@ public async Task TestConnectAs()
3538
{
3639
var testRunner = new RealTimeTestRunner();
3740

38-
testRunner.Connect(username: "sys", password: "Oradoc_db1", database: "orclpdb1", connectAs: "sysdba");
41+
testRunner.Connect(username: "sys", password: "oracle", database: database, connectAs: "sysdba");
3942

4043
try
4144
{
@@ -56,7 +59,7 @@ public async Task TestRunTestsWithCoverage()
5659
{
5760
var testRunner = new RealTimeTestRunner();
5861

59-
testRunner.Connect(username: "ut3_tester", password: "ut3", database: "orclpdb1");
62+
testRunner.Connect(username, password, database);
6063

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

@@ -75,9 +78,11 @@ public void TestRunTestsAndAbort()
7578
{
7679
var testRunner = new RealTimeTestRunner();
7780

78-
testRunner.Connect(username: "ut3_tester", password: "ut3", database: "orclpdb1");
81+
testRunner.Connect(username, password, database);
7982

83+
#pragma warning disable CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed
8084
testRunner.RunTestsAsync("ut3_tester.test_ut_test", @event => { });
85+
#pragma warning restore CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed
8186

8287
testRunner.Close();
8388
}
@@ -87,7 +92,7 @@ public async Task TestRunTestsTwoTimes()
8792
{
8893
var testRunner = new RealTimeTestRunner();
8994

90-
testRunner.Connect(username: "ut3_tester", password: "ut3", database: "orclpdb1");
95+
testRunner.Connect(username, password, database);
9196

9297
var events1 = new List<@event>();
9398
Task task1 = testRunner.RunTestsAsync("ut3_tester.test_ut_test", @event =>
@@ -111,9 +116,9 @@ public void TestGetVersion()
111116
{
112117
var testRunner = new RealTimeTestRunner();
113118

114-
testRunner.Connect(username: "ut3_tester", password: "ut3", database: "orclpdb1");
119+
testRunner.Connect(username, password, database);
115120

116-
string version = testRunner.GetVersion();
121+
var version = testRunner.GetVersion();
117122

118123
Assert.AreEqual("v3.1.11.3469-develop", version);
119124

@@ -125,11 +130,11 @@ public void TestGetVersionWhenNotInstalled()
125130
{
126131
var testRunner = new RealTimeTestRunner();
127132

128-
testRunner.Connect(username: "ut3_tester", password: "ut3", database: "orclpdb1");
133+
testRunner.Connect(username, password, database);
129134

130135
try
131136
{
132-
string version = testRunner.GetVersion();
137+
var version = testRunner.GetVersion();
133138
Assert.Fail();
134139
}
135140
catch (OracleException e)

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

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using System.Reflection;
1+
using System.Reflection;
22
using System.Runtime.CompilerServices;
33
using System.Runtime.InteropServices;
44

@@ -10,7 +10,7 @@
1010
[assembly: AssemblyConfiguration("")]
1111
[assembly: AssemblyCompany("utPLSQL.org")]
1212
[assembly: AssemblyProduct("utPLSQL.Api")]
13-
[assembly: AssemblyCopyright("Copyright © 2021")]
13+
[assembly: AssemblyCopyright("Copyright © 2021")]
1414
[assembly: AssemblyTrademark("")]
1515
[assembly: AssemblyCulture("")]
1616

@@ -29,8 +29,5 @@
2929
// Build Number
3030
// Revision
3131
//
32-
// You can specify all the values or you can default the Build and Revision Numbers
33-
// by using the '*' as shown below:
34-
// [assembly: AssemblyVersion("1.0.*")]
35-
[assembly: AssemblyVersion("1.5.2.0")]
36-
[assembly: AssemblyFileVersion("1.5.2.0")]
32+
[assembly: AssemblyVersion("1.5.4.0")]
33+
[assembly: AssemblyFileVersion("1.5.4.0")]

utPLSQL.Api/utPLSQL.Api/RealTimeTestRunner.cs

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -17,34 +17,34 @@ public override async Task RunTestsAsync(List<string> paths, Action<@event> cons
1717
{
1818
if (paths != null && paths.Count > 0)
1919
{
20-
string realtimeReporterId = Guid.NewGuid().ToString().Replace("-", "");
20+
var realtimeReporterId = Guid.NewGuid().ToString().Replace("-", "");
2121

22-
Task taskRun = Task.Run(() => { UtRun(realtimeReporterId, paths); });
23-
Task taskConsume = Task.Run(() => { ConsumeResult(realtimeReporterId, consumer); });
22+
var taskRun = Task.Run(() => UtRun(realtimeReporterId, paths));
23+
var taskConsume = Task.Run(() => ConsumeResult(realtimeReporterId, consumer));
2424

2525
await Task.WhenAll(taskRun, taskConsume);
2626
}
2727
}
2828

2929
public override async Task RunTestsAsync(string path, Action<@event> consumer)
3030
{
31-
await RunTestsAsync(new List<string>() { path }, consumer);
31+
await RunTestsAsync(new List<string> { path }, consumer);
3232
}
3333

3434
public override async Task<string> RunTestsWithCoverageAsync(List<string> paths, Action<@event> consumer, List<string> coverageSchemas = null, List<string> includeObjects = null, List<string> excludeObjects = null)
3535
{
3636
if (paths != null && paths.Count > 0)
3737
{
38-
string realtimeReporterId = Guid.NewGuid().ToString().Replace("-", "");
39-
string coverageReporterId = Guid.NewGuid().ToString().Replace("-", "");
38+
var realtimeReporterId = Guid.NewGuid().ToString().Replace("-", "");
39+
var coverageReporterId = Guid.NewGuid().ToString().Replace("-", "");
4040

41-
Task taskRun = Task.Run(() => { UtRunWithCoverage(realtimeReporterId, coverageReporterId, paths, coverageSchemas, includeObjects, excludeObjects); });
42-
Task taskConsume = Task.Run(() => { ConsumeResult(realtimeReporterId, consumer); });
43-
Task<string> taskCoverateReport = Task.Run(() => { return GetCoverageReport(coverageReporterId); });
41+
var taskRun = Task.Run(() => UtRunWithCoverage(realtimeReporterId, coverageReporterId, paths, coverageSchemas, includeObjects, excludeObjects));
42+
var taskConsume = Task.Run(() => ConsumeResult(realtimeReporterId, consumer));
43+
var taskCoverageReport = Task.Run(() => GetCoverageReport(coverageReporterId));
4444

45-
await Task.WhenAll(taskRun, taskConsume, taskCoverateReport);
45+
await Task.WhenAll(taskRun, taskConsume, taskCoverageReport);
4646

47-
return taskCoverateReport.Result;
47+
return taskCoverageReport.Result;
4848
}
4949
else
5050
{
@@ -54,7 +54,7 @@ public override async Task<string> RunTestsWithCoverageAsync(List<string> paths,
5454

5555
public override async Task<string> RunTestsWithCoverageAsync(string path, Action<@event> consumer, string coverageSchema = null, List<string> includeObjects = null, List<string> excludeObjects = null)
5656
{
57-
return await RunTestsWithCoverageAsync(new List<string>() { path }, consumer, new List<string>() { coverageSchema }, includeObjects, excludeObjects);
57+
return await RunTestsWithCoverageAsync(new List<string> { path }, consumer, new List<string> { coverageSchema }, includeObjects, excludeObjects);
5858
}
5959

6060
private void UtRunWithCoverage(string realtimeReporterId, string coverageReporterId, List<string> paths, List<string> coverageSchemas, List<string> includeObjects, List<string> excludeObjects)

utPLSQL.Api/utPLSQL.Api/TestRunner.cs

Lines changed: 32 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,10 @@ namespace utPLSQL
1313
/// <typeparam name="T">Type of result class used in callback action</typeparam>
1414
public abstract class TestRunner<T>
1515
{
16-
internal OracleConnection produceConnection;
17-
internal OracleConnection consumeConnection;
16+
protected OracleConnection produceConnection;
17+
protected OracleConnection consumeConnection;
1818

19-
protected List<OracleCommand> runningCommands = new List<OracleCommand>();
19+
protected readonly List<OracleCommand> runningCommands = new List<OracleCommand>();
2020

2121
/// <summary>
2222
/// Connects to the database.
@@ -38,7 +38,7 @@ public void Connect(string username, string password, string database, string co
3838
connectionString = $"User Id={username};DBA Privilege={connectAs};Password={password};Data Source={database}";
3939
}
4040

41-
foreach (OracleCommand command in runningCommands)
41+
foreach (var command in runningCommands)
4242
{
4343
command.Cancel();
4444
}
@@ -49,25 +49,48 @@ public void Connect(string username, string password, string database, string co
4949
consumeConnection = new OracleConnection(connectionString);
5050
consumeConnection.Open();
5151
}
52+
5253
/// <summary>
5354
/// Closes both connections
5455
/// </summary>
5556
public void Close()
5657
{
57-
produceConnection?.Close();
58-
consumeConnection?.Close();
58+
foreach (var command in runningCommands)
59+
{
60+
command.Cancel();
61+
}
62+
63+
if (produceConnection != null)
64+
{
65+
try {
66+
produceConnection.Close();
67+
}
68+
catch
69+
{
70+
}
71+
}
72+
if (consumeConnection != null)
73+
{
74+
try
75+
{
76+
consumeConnection.Close();
77+
}
78+
catch
79+
{
80+
}
81+
}
5982
}
6083

6184
/// <summary>
6285
/// Returns the installed utPLSQL version
6386
/// </summary>
6487
/// <returns>Version as string</returns>
65-
public String GetVersion()
88+
public string GetVersion()
6689
{
6790
var cmd = new OracleCommand("select ut.version() from dual", produceConnection);
6891
runningCommands.Add(cmd);
6992

70-
OracleDataReader reader = cmd.ExecuteReader();
93+
var reader = cmd.ExecuteReader();
7194
reader.Read();
7295

7396
var version = reader.GetString(0);
@@ -155,7 +178,7 @@ protected string GetCoverageReport(string id)
155178
protected string ConvertToUtVarchar2List(List<string> elements)
156179
{
157180
var sb = new StringBuilder();
158-
bool first = true;
181+
var first = true;
159182
foreach (var element in elements)
160183
{
161184
if (!first)

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,15 @@
22
<package >
33
<metadata>
44
<id>utPLSQL.Api</id>
5-
<version>1.5.2</version>
5+
<version>1.5.4</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>Only interal async behavoir changed</releaseNotes>
13+
<releaseNotes>Cancel running commands when closing</releaseNotes>
1414
<copyright>Copyright © 2021</copyright>
1515
<tags>utPLSQL</tags>
1616
</metadata>

0 commit comments

Comments
 (0)