Skip to content

Commit a71ee70

Browse files
committed
#5 Get version to check if utPLSQL is installed
1 parent 7b5f37a commit a71ee70

File tree

6 files changed

+98
-18
lines changed

6 files changed

+98
-18
lines changed

PlsqlDeveloperUtPlsqlPlugin/utPLSQL.Api.Test/RealTimeTestRunnerTest.cs

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using Microsoft.VisualStudio.TestTools.UnitTesting;
2+
using Oracle.ManagedDataAccess.Client;
23
using System.Collections.Generic;
34
using System.Linq;
45

@@ -28,5 +29,33 @@ public void TestToscamtest()
2829

2930
System.Diagnostics.Trace.WriteLine(report);
3031
}
32+
33+
[TestMethod]
34+
public void TestGetVersion()
35+
{
36+
var testRunner = new RealTimeTestRunner();
37+
testRunner.Connect(username: "toscamtest", password: "toscamtest", database: "CA40");
38+
39+
string version = testRunner.GetVersion();
40+
41+
Assert.AreEqual("v3.1.7.3096", version);
42+
}
43+
44+
[TestMethod]
45+
public void TestGetVersionWhenNotInstalled()
46+
{
47+
var testRunner = new RealTimeTestRunner();
48+
testRunner.Connect(username: "c##sakila", password: "sakila", database: "ORCLCDB");
49+
50+
try
51+
{
52+
string version = testRunner.GetVersion();
53+
Assert.Fail();
54+
}
55+
catch (OracleException e)
56+
{
57+
Assert.AreEqual("ORA-00904: \"UT\".\"VERSION\": ungültige ID", e.Message);
58+
}
59+
}
3160
}
3261
}
Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,31 @@
1-
<?xml version="1.0" encoding="utf-8"?>
1+
<?xml version="1.0" encoding="utf-8"?>
22
<configuration>
3-
<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.2"/></startup></configuration>
3+
<configSections>
4+
<section name="oracle.manageddataaccess.client"
5+
type="OracleInternal.Common.ODPMSectionHandler, Oracle.ManagedDataAccess, Version=4.122.19.1, Culture=neutral, PublicKeyToken=89b483f429c47342"/>
6+
</configSections>
7+
<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.2"/></startup>
8+
<system.data>
9+
<DbProviderFactories>
10+
<remove invariant="Oracle.ManagedDataAccess.Client"/>
11+
<add name="ODP.NET, Managed Driver" invariant="Oracle.ManagedDataAccess.Client" description="Oracle Data Provider for .NET, Managed Driver"
12+
type="Oracle.ManagedDataAccess.Client.OracleClientFactory, Oracle.ManagedDataAccess, Version=4.122.19.1, Culture=neutral, PublicKeyToken=89b483f429c47342"/>
13+
</DbProviderFactories>
14+
</system.data>
15+
<runtime>
16+
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
17+
<dependentAssembly>
18+
<publisherPolicy apply="no"/>
19+
<assemblyIdentity name="Oracle.ManagedDataAccess" publicKeyToken="89b483f429c47342" culture="neutral"/>
20+
<bindingRedirect oldVersion="4.121.0.0 - 4.65535.65535.65535" newVersion="4.122.19.1"/>
21+
</dependentAssembly>
22+
</assemblyBinding>
23+
</runtime>
24+
<oracle.manageddataaccess.client>
25+
<version number="*">
26+
<dataSources>
27+
<dataSource alias="SampleDataSource" descriptor="(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=localhost)(PORT=1521))(CONNECT_DATA=(SERVICE_NAME=ORCL))) "/>
28+
</dataSources>
29+
</version>
30+
</oracle.manageddataaccess.client>
31+
</configuration>

PlsqlDeveloperUtPlsqlPlugin/utPLSQL.Api.Test/packages.config

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,5 @@
22
<packages>
33
<package id="MSTest.TestAdapter" version="2.1.2" targetFramework="net472" />
44
<package id="MSTest.TestFramework" version="2.1.2" targetFramework="net472" />
5+
<package id="Oracle.ManagedDataAccess" version="19.10.0" targetFramework="net472" />
56
</packages>

PlsqlDeveloperUtPlsqlPlugin/utPLSQL.Api.Test/utPLSQL.Api.Test.csproj

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,9 @@
4747
<Reference Include="Microsoft.VisualStudio.TestPlatform.TestFramework.Extensions, Version=14.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
4848
<HintPath>..\packages\MSTest.TestFramework.2.1.2\lib\net45\Microsoft.VisualStudio.TestPlatform.TestFramework.Extensions.dll</HintPath>
4949
</Reference>
50+
<Reference Include="Oracle.ManagedDataAccess, Version=4.122.19.1, Culture=neutral, PublicKeyToken=89b483f429c47342, processorArchitecture=MSIL">
51+
<HintPath>..\packages\Oracle.ManagedDataAccess.19.10.0\lib\net40\Oracle.ManagedDataAccess.dll</HintPath>
52+
</Reference>
5053
<Reference Include="System" />
5154
<Reference Include="System.Core" />
5255
<Reference Include="System.Xml.Linq" />

PlsqlDeveloperUtPlsqlPlugin/utPLSQL.Api/TestRunner.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,16 @@ public void Close()
3535
consumeConnection?.Close();
3636
}
3737

38+
public String GetVersion()
39+
{
40+
var cmd = new OracleCommand("select ut.version() from dual", produceConnection);
41+
OracleDataReader reader = cmd.ExecuteReader();
42+
reader.Read();
43+
var version = reader.GetString(0);
44+
reader.Close();
45+
return version;
46+
}
47+
3848
public abstract void RunTests(string type, string owner, string name, string procedure);
3949

4050
public abstract void RunTestsWithCoverage(string type, string owner, string name, string procedure, string coverageSchemas,

PlsqlDeveloperUtPlsqlPlugin/utPLSQL.UI/TestRunnerWindow.cs

Lines changed: 25 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -51,31 +51,40 @@ public void RunTestsAsync(string type, string owner, string name, string procedu
5151

5252
SetWindowTitle(type, owner, name, procedure);
5353

54-
if (coverage)
54+
try
5555
{
56-
var codeCoverageReportDialog = new CodeCoverageReportDialog(GetPath(type, owner, name, procedure));
57-
var dialogResult = codeCoverageReportDialog.ShowDialog();
58-
if (dialogResult == DialogResult.OK)
56+
testRunner.GetVersion();
57+
58+
if (coverage)
5959
{
60-
txtStatus.Text = "Running tests with coverage...";
60+
var codeCoverageReportDialog = new CodeCoverageReportDialog(GetPath(type, owner, name, procedure));
61+
var dialogResult = codeCoverageReportDialog.ShowDialog();
62+
if (dialogResult == DialogResult.OK)
63+
{
64+
txtStatus.Text = "Running tests with coverage...";
6165

62-
RunWithCoverage(type, owner, name, procedure, codeCoverageReportDialog);
66+
RunWithCoverage(type, owner, name, procedure, codeCoverageReportDialog);
6367

64-
Show();
68+
Show();
6569

66-
CollectResults(true);
67-
CollectReport();
70+
CollectResults(true);
71+
CollectReport();
72+
}
6873
}
69-
}
70-
else
71-
{
72-
txtStatus.Text = "Running tests...";
74+
else
75+
{
76+
txtStatus.Text = "Running tests...";
7377

74-
RunTests(type, owner, name, procedure);
78+
RunTests(type, owner, name, procedure);
7579

76-
Show();
80+
Show();
7781

78-
CollectResults(false);
82+
CollectResults(false);
83+
}
84+
}
85+
catch (Exception e)
86+
{
87+
MessageBox.Show("utPLSQL is not installed", "utPLSQL not installed", MessageBoxButtons.OK, MessageBoxIcon.Error);
7988
}
8089
}
8190

0 commit comments

Comments
 (0)