diff --git a/utPLSQL.Api/utPLSQL.Api.Test/App.config b/utPLSQL.Api/utPLSQL.Api.Test/App.config index d4ec22d..7b54b1e 100644 --- a/utPLSQL.Api/utPLSQL.Api.Test/App.config +++ b/utPLSQL.Api/utPLSQL.Api.Test/App.config @@ -1,14 +1,12 @@ - + -
+
- + @@ -27,4 +25,4 @@ - \ No newline at end of file + diff --git a/utPLSQL.Api/utPLSQL.Api.Test/Properties/AssemblyInfo.cs b/utPLSQL.Api/utPLSQL.Api.Test/Properties/AssemblyInfo.cs index e9ee17e..251f4f9 100644 --- a/utPLSQL.Api/utPLSQL.Api.Test/Properties/AssemblyInfo.cs +++ b/utPLSQL.Api/utPLSQL.Api.Test/Properties/AssemblyInfo.cs @@ -29,5 +29,5 @@ // Build Number // Revision // -[assembly: AssemblyVersion("1.5.4.0")] -[assembly: AssemblyFileVersion("1.5.4.0")] +[assembly: AssemblyVersion("3.1.6")] +[assembly: AssemblyFileVersion("3.1.6")] diff --git a/utPLSQL.Api/utPLSQL.Api.Test/RealTimeTestRunnerTest.cs b/utPLSQL.Api/utPLSQL.Api.Test/RealTimeTestRunnerTest.cs index ad2e522..54a659a 100644 --- a/utPLSQL.Api/utPLSQL.Api.Test/RealTimeTestRunnerTest.cs +++ b/utPLSQL.Api/utPLSQL.Api.Test/RealTimeTestRunnerTest.cs @@ -10,9 +10,9 @@ namespace utPLSQL [TestClass] public class RealTimeTestRunnerTest { - const string username = "ut3_tester"; - const string password = "ut3"; - const string database = "xepdb1"; + const string username = "TESTS_OWNER"; + const string password = "pass"; + const string database = "XE"; [TestMethod] public async Task TestRunTests() @@ -22,7 +22,7 @@ public async Task TestRunTests() testRunner.Connect(username, password, database); var events = new List<@event>(); - await testRunner.RunTestsAsync("ut3_tester.test_ut_test", @event => + await testRunner.RunTestsAsync("TESTS_OWNER.TEST_PKG_TEST_ME", @event => { events.Add(@event); }); @@ -42,7 +42,7 @@ public async Task TestConnectAs() try { - await testRunner.RunTestsAsync("ut3_tester.test_ut_test", @event => { }); + await testRunner.RunTestsAsync("TESTS_OWNER.TEST_PKG_TEST_ME", @event => { }); Assert.Fail(); } @@ -63,8 +63,8 @@ public async Task TestRunTestsWithCoverage() var events = new List<@event>(); - string report = await testRunner.RunTestsWithCoverageAsync(path: "ut3_tester.test_ut_test", consumer: @event => { events.Add(@event); }, - coverageSchema: "ut3_develop", includeObjects: new List() { "ut_test" }); + string report = await testRunner.RunTestsWithCoverageAsync(path: "TESTS_OWNER.TEST_PKG_TEST_ME", consumer: @event => { events.Add(@event); }, + coverageSchema: "CODE_OWNER", includeObjects: new List() { "PKG_TEST_ME" }); Logger.LogMessage(report); Assert.AreEqual("pre-run", events[0].type); @@ -95,13 +95,13 @@ public async Task TestRunTestsTwoTimes() testRunner.Connect(username, password, database); var events1 = new List<@event>(); - Task task1 = testRunner.RunTestsAsync("ut3_tester.test_ut_test", @event => + Task task1 = testRunner.RunTestsAsync("TESTS_OWNER.TEST_PKG_TEST_ME", @event => { events1.Add(@event); }); var events2 = new List<@event>(); - Task task2 = testRunner.RunTestsAsync("ut3_tester.test_ut_test", @event => + Task task2 = testRunner.RunTestsAsync("TESTS_OWNER.TEST_PKG_TEST_ME", @event => { events2.Add(@event); }); @@ -120,7 +120,7 @@ public void TestGetVersion() var version = testRunner.GetVersion(); - Assert.AreEqual("v3.1.11.3469-develop", version); + Assert.AreEqual("v3.1.11.3559", version); testRunner.Close(); } diff --git a/utPLSQL.Api/utPLSQL.Api.Test/utPLSQL.Api.Test.csproj b/utPLSQL.Api/utPLSQL.Api.Test/utPLSQL.Api.Test.csproj index 8b28715..d2e4ba0 100644 --- a/utPLSQL.Api/utPLSQL.Api.Test/utPLSQL.Api.Test.csproj +++ b/utPLSQL.Api/utPLSQL.Api.Test/utPLSQL.Api.Test.csproj @@ -10,7 +10,7 @@ Properties utPLSQL.Api.Test utPLSQL.Api.Test - v4.7.2 + v4.8 512 {3AC096D0-A1C2-E12C-1390-A8335801FDAB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} 15.0 @@ -20,6 +20,7 @@ UnitTest + true @@ -68,12 +69,5 @@ - - - This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. - - - - \ No newline at end of file diff --git a/utPLSQL.Api/utPLSQL.Api/App.config b/utPLSQL.Api/utPLSQL.Api/App.config index 292458b..7b54b1e 100644 --- a/utPLSQL.Api/utPLSQL.Api/App.config +++ b/utPLSQL.Api/utPLSQL.Api/App.config @@ -25,4 +25,4 @@ - + diff --git a/utPLSQL.Api/utPLSQL.Api/Properties/AssemblyInfo.cs b/utPLSQL.Api/utPLSQL.Api/Properties/AssemblyInfo.cs index 0b1de9c..1dee011 100644 --- a/utPLSQL.Api/utPLSQL.Api/Properties/AssemblyInfo.cs +++ b/utPLSQL.Api/utPLSQL.Api/Properties/AssemblyInfo.cs @@ -29,5 +29,5 @@ // Build Number // Revision // -[assembly: AssemblyVersion("1.5.4.0")] -[assembly: AssemblyFileVersion("1.5.4.0")] +[assembly: AssemblyVersion("3.1.6")] +[assembly: AssemblyFileVersion("3.1.6")] diff --git a/utPLSQL.Api/utPLSQL.Api/TestRunner.cs b/utPLSQL.Api/utPLSQL.Api/TestRunner.cs index 2dc8cc8..d0e3615 100644 --- a/utPLSQL.Api/utPLSQL.Api/TestRunner.cs +++ b/utPLSQL.Api/utPLSQL.Api/TestRunner.cs @@ -2,6 +2,7 @@ using System; using System.Collections.Generic; using System.Data; +using System.Diagnostics; using System.Text; using System.Threading.Tasks; @@ -28,28 +29,39 @@ public abstract class TestRunner /// Connect as public void Connect(string username, string password, string database, string connectAs = null) { - string connectionString; - if (string.IsNullOrEmpty(connectAs)) + try { - connectionString = $"User Id={username};Password={password};Data Source={database}"; - } - else - { - connectionString = $"User Id={username};DBA Privilege={connectAs};Password={password};Data Source={database}"; - } + string connectionString; + if (string.IsNullOrEmpty(connectAs)) + { + connectionString = $"User Id={username};Password={password};Data Source={database}"; + } + else + { + connectionString = $"User Id={username};DBA Privilege={connectAs};Password={password};Data Source={database}"; + } - foreach (var command in runningCommands) - { - command.Cancel(); - } + foreach (var command in runningCommands) + { + command.Cancel(); + } - produceConnection = new OracleConnection(connectionString); - produceConnection.Open(); + produceConnection = new OracleConnection(connectionString); + produceConnection.Open(); - consumeConnection = new OracleConnection(connectionString); - consumeConnection.Open(); + consumeConnection = new OracleConnection(connectionString); + consumeConnection.Open(); + } + catch (Exception e) + { + using (EventLog eventLog = new EventLog("Application")) + { + eventLog.Source = "Application"; + eventLog.WriteEntry($"{e.Message}\r\n{e.StackTrace}", EventLogEntryType.Error); + } + } } - + /// /// Closes both connections /// @@ -62,11 +74,17 @@ public void Close() if (produceConnection != null) { - try { - produceConnection.Close(); + try + { + produceConnection.Close(); } - catch + catch (Exception e) { + using (EventLog eventLog = new EventLog("Application")) + { + eventLog.Source = "Application"; + eventLog.WriteEntry($"{e.Message}\r\n{e.StackTrace}", EventLogEntryType.Error); + } } } if (consumeConnection != null) @@ -75,8 +93,13 @@ public void Close() { consumeConnection.Close(); } - catch + catch (Exception e) { + using (EventLog eventLog = new EventLog("Application")) + { + eventLog.Source = "Application"; + eventLog.WriteEntry($"{e.Message}\r\n{e.StackTrace}", EventLogEntryType.Error); + } } } } @@ -87,20 +110,32 @@ public void Close() /// Version as string public string GetVersion() { - var cmd = new OracleCommand("select ut.version() from dual", produceConnection); - runningCommands.Add(cmd); + try + { + var cmd = new OracleCommand("select ut.version() from dual", produceConnection); + runningCommands.Add(cmd); - var reader = cmd.ExecuteReader(); - reader.Read(); + var reader = cmd.ExecuteReader(); + reader.Read(); - var version = reader.GetString(0); + var version = reader.GetString(0); - reader.Close(); + reader.Close(); - runningCommands.Remove(cmd); - cmd.Dispose(); + runningCommands.Remove(cmd); + cmd.Dispose(); - return version; + return version; + } + catch (Exception e) + { + using (EventLog eventLog = new EventLog("Application")) + { + eventLog.Source = "Application"; + eventLog.WriteEntry($"{e.Message}\r\n{e.StackTrace}", EventLogEntryType.Error); + } + return null; + } } /// @@ -141,38 +176,50 @@ public string GetVersion() protected string GetCoverageReport(string id) { - var sb = new StringBuilder(); + try + { + var sb = new StringBuilder(); - var proc = @"DECLARE + var proc = @"DECLARE l_reporter ut_coverage_html_reporter := ut_coverage_html_reporter(); BEGIN l_reporter.set_reporter_id(:id); :lines_cursor := l_reporter.get_lines_cursor(); END;"; - var cmd = new OracleCommand(proc, consumeConnection); - runningCommands.Add(cmd); + var cmd = new OracleCommand(proc, consumeConnection); + runningCommands.Add(cmd); - cmd.Parameters.Add("id", OracleDbType.Varchar2, ParameterDirection.Input).Value = id; - cmd.Parameters.Add("lines_cursor", OracleDbType.RefCursor, ParameterDirection.Output); + cmd.Parameters.Add("id", OracleDbType.Varchar2, ParameterDirection.Input).Value = id; + cmd.Parameters.Add("lines_cursor", OracleDbType.RefCursor, ParameterDirection.Output); - // https://stackoverflow.com/questions/2226769/bad-performance-with-oracledatareader - cmd.InitialLOBFetchSize = -1; + // https://stackoverflow.com/questions/2226769/bad-performance-with-oracledatareader + cmd.InitialLOBFetchSize = -1; - var reader = cmd.ExecuteReader(); + var reader = cmd.ExecuteReader(); - while (reader.Read()) - { - var line = reader.GetString(0); - sb.Append(line); - } + while (reader.Read()) + { + var line = reader.GetString(0); + sb.Append(line); + } - reader.Close(); + reader.Close(); - runningCommands.Remove(cmd); - cmd.Dispose(); + runningCommands.Remove(cmd); + cmd.Dispose(); - return sb.ToString(); + return sb.ToString(); + } + catch (Exception e) + { + using (EventLog eventLog = new EventLog("Application")) + { + eventLog.Source = "Application"; + eventLog.WriteEntry($"{e.Message}\r\n{e.StackTrace}", EventLogEntryType.Error); + } + return null; + } } protected string ConvertToUtVarchar2List(List elements) diff --git a/utPLSQL.Api/utPLSQL.Api/utPLSQL.Api.csproj b/utPLSQL.Api/utPLSQL.Api/utPLSQL.Api.csproj index ec357f9..9ec956c 100644 --- a/utPLSQL.Api/utPLSQL.Api/utPLSQL.Api.csproj +++ b/utPLSQL.Api/utPLSQL.Api/utPLSQL.Api.csproj @@ -9,7 +9,7 @@ Properties utPLSQL.Api utPLSQL.Api - v4.5 + v4.8 512 true diff --git a/utPLSQL.Api/utPLSQL.Api/utPLSQL.Api.nuspec b/utPLSQL.Api/utPLSQL.Api/utPLSQL.Api.nuspec index 8e3e340..0805495 100644 --- a/utPLSQL.Api/utPLSQL.Api/utPLSQL.Api.nuspec +++ b/utPLSQL.Api/utPLSQL.Api/utPLSQL.Api.nuspec @@ -2,7 +2,7 @@ utPLSQL.Api - 1.5.4 + 1.5.6 utPLSQL API Simon Martinelli false @@ -10,7 +10,7 @@ https://github.com/utPLSQL/utPLSQL-dotnet-api images/blue-icon-transparent.png .NET API for utPLSQL - Cancel running commands when closing + Log exceptions removed Copyright © 2021 utPLSQL