assert non-disposed status for plugin in each routine, closes #1

This commit is contained in:
Florian Förster 2025-03-21 09:05:15 +01:00
parent 7c8b241235
commit 763dbf5038
4 changed files with 25 additions and 22 deletions

View File

@ -42,7 +42,7 @@ namespace dopt.DeltaBarth.Tests
Assert.AreEqual("caused by test", parsed.message);
Assert.IsNull(parsed.apiServerError);
PrettyPrint(parsed);
plugin.Shutdown();
plugin.Dispose();
}
[TestMethod]
public void Parse_ApiError_Test()
@ -62,7 +62,7 @@ namespace dopt.DeltaBarth.Tests
Assert.IsNull(parsed.title);
Assert.IsNull(parsed.traceId);
PrettyPrint(parsed);
plugin.Shutdown();
plugin.Dispose();
}
[TestMethod]
public void Parse_Credentials_Test()
@ -79,7 +79,7 @@ namespace dopt.DeltaBarth.Tests
Assert.AreEqual("test1", parsed.database);
Assert.AreEqual("mandant1", parsed.mandant);
PrettyPrint(parsed);
plugin.Shutdown();
plugin.Dispose();
}
[TestMethod]
public void Parse_SalesPrognosisResult_Test()
@ -95,7 +95,7 @@ namespace dopt.DeltaBarth.Tests
Assert.AreEqual(12, parsed.monat);
Assert.AreEqual(3000.3456m, parsed.vorhersage);
PrettyPrint(parsed);
plugin.Shutdown();
plugin.Dispose();
}
[TestMethod]
public void Parse_SalesPrognosisResults_Test()
@ -118,7 +118,7 @@ namespace dopt.DeltaBarth.Tests
Assert.AreEqual(arr[i], parsed.daten[i]);
}
PrettyPrint(parsed);
plugin.Shutdown();
plugin.Dispose();
}
[TestMethod]
public void Parse_SalesPrognosisExport_Test()
@ -147,7 +147,7 @@ namespace dopt.DeltaBarth.Tests
Assert.AreEqual(data.daten[i], parsed.response.daten[i]);
}
PrettyPrint(parsed);
plugin.Shutdown();
plugin.Dispose();
}
}
}

View File

@ -62,7 +62,7 @@ namespace dopt.DeltaBarth.Tests
public void ConstructInitialiseFinalise_Test()
{
var test = new TPlugin();
test.Shutdown();
test.Dispose();
}
[TestMethod]
public void Set_and_Obtain_Credentials_Test()
@ -76,7 +76,7 @@ namespace dopt.DeltaBarth.Tests
Assert.AreEqual(password, creds.password);
Assert.AreEqual(database, creds.database);
Assert.AreEqual(mandant, creds.mandant);
test.Shutdown();
test.Dispose();
}
[TestMethod]
public void Set_and_Obtain_BaseApiUrl_Test()
@ -87,7 +87,7 @@ namespace dopt.DeltaBarth.Tests
var apiUrlGet = test.GetBaseApiUrl();
Console.WriteLine($"Result from Python session was: {apiUrlGet}");
Assert.AreEqual(apiUrlSet, apiUrlGet);
test.Shutdown();
test.Dispose();
}
[TestMethod]
public void Startup_Test()
@ -104,7 +104,7 @@ namespace dopt.DeltaBarth.Tests
Assert.AreEqual(password, creds.password);
Assert.AreEqual(database, creds.database);
Assert.AreEqual(mandant, creds.mandant);
test.Shutdown();
test.Dispose();
}
[TestMethod]
public void UmsatzprognoseDummy_WithoutParams_Test()
@ -114,7 +114,7 @@ namespace dopt.DeltaBarth.Tests
test.Startup(apiUrlSet, user, password, database, mandant);
var res = test.UmsatzprognoseDummy(null, null);
PrettyPrint(res);
test.Shutdown();
test.Dispose();
}
[TestMethod]
public void UmsatzprognoseDummy_WithCompanyIdWithoutDate_Test()
@ -125,7 +125,7 @@ namespace dopt.DeltaBarth.Tests
var comp_id = 1000;
var res = test.UmsatzprognoseDummy(comp_id, null);
PrettyPrint(res);
test.Shutdown();
test.Dispose();
}
[TestMethod]
public void UmsatzprognoseDummy_WithoutCompanyIdWithDate_Test()
@ -136,7 +136,7 @@ namespace dopt.DeltaBarth.Tests
var date = new DateTime(2023, 1, 1, 12, 45, 30);
var res = test.UmsatzprognoseDummy(null, date);
PrettyPrint(res);
test.Shutdown();
test.Dispose();
}
[TestMethod]
@ -149,7 +149,7 @@ namespace dopt.DeltaBarth.Tests
var comp_id = 1024;
var res = test.Umsatzprognose(comp_id, null);
PrettyPrint(res);
test.Shutdown();
test.Dispose();
}
[TestMethod]
[TestCategory("ActiveAPI")]
@ -161,7 +161,7 @@ namespace dopt.DeltaBarth.Tests
var date = new DateTime(2030, 1, 1, 12, 45, 30);
var res = test.Umsatzprognose(null, date);
PrettyPrint(res);
test.Shutdown();
test.Dispose();
}
[TestMethod]
[TestCategory("ActiveAPI")]
@ -173,7 +173,7 @@ namespace dopt.DeltaBarth.Tests
var date = new DateTime(2015, 1, 1, 12, 45, 30);
var res = test.Umsatzprognose(null, date);
PrettyPrint(res);
test.Shutdown();
test.Dispose();
}
}
}

View File

@ -18,25 +18,25 @@ namespace dopt.DeltaBarth
}
public void Startup(string basisApiUrl, string nutzername, string passwort, string datenbank, string mandant)
{
AssertNotDisposed();
SetzeBasisApiUrl(basisApiUrl);
SetzeNutzerdaten(nutzername, passwort, datenbank, mandant);
}
public void Shutdown()
{
base.Finalise();
}
public void SetzeBasisApiUrl(string basisApiUrl)
{
AssertNotDisposed();
pyModManagement.set_base_url(basisApiUrl);
}
public void SetzeNutzerdaten(string nutzername, string passwort, string datenbank, string mandant)
{
AssertNotDisposed();
using (Py.GIL()) {
pyModManagement.set_credentials(nutzername, passwort, datenbank, mandant);
}
}
public JsonStructs.UmsatzPrognoseAusgabe UmsatzprognoseDummy(int? firmaId, DateTime? buchungsDatum)
{
AssertNotDisposed();
string pyJson;
using (Py.GIL())
{
@ -48,6 +48,7 @@ namespace dopt.DeltaBarth
}
public JsonStructs.UmsatzPrognoseAusgabe Umsatzprognose(int? firmaId, DateTime? buchungsDatum)
{
AssertNotDisposed();
string pyJson;
using (Py.GIL())
{
@ -59,6 +60,7 @@ namespace dopt.DeltaBarth
}
protected string GetBaseApiUrl()
{
AssertNotDisposed();
string pyJson;
using (Py.GIL())
{
@ -68,6 +70,7 @@ namespace dopt.DeltaBarth
}
protected JsonStructs.Credentials GetCredentials()
{
AssertNotDisposed();
string pyJson;
using (Py.GIL())
{

View File

@ -10,7 +10,7 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="dopt.SharpPython" Version="0.2.1" />
<PackageReference Include="dopt.SharpPython" Version="0.3.0" />
<Content Include="..\python\**\*">
<Link>python\%(RecursiveDir)/%(FileName)%(Extension)</Link>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>