From e298c2ce51da01f81e5d17b2b9648370aa0d73fc Mon Sep 17 00:00:00 2001 From: foefl Date: Thu, 3 Apr 2025 13:05:40 +0200 Subject: [PATCH] assert no pipeline crash if API server is not available, fix #8 --- dopt.DeltaBarth.Tests/PluginTest.cs | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/dopt.DeltaBarth.Tests/PluginTest.cs b/dopt.DeltaBarth.Tests/PluginTest.cs index 940cea9..47baf18 100644 --- a/dopt.DeltaBarth.Tests/PluginTest.cs +++ b/dopt.DeltaBarth.Tests/PluginTest.cs @@ -4,6 +4,7 @@ using static Microsoft.ApplicationInsights.MetricDimensionNames.TelemetryContext namespace dopt.DeltaBarth.Tests { + using System.Text.Encodings.Web; using Microsoft.Extensions.Configuration; internal class Config { @@ -65,6 +66,7 @@ namespace dopt.DeltaBarth.Tests { string prettyJson = JsonSerializer.Serialize(toSerialise, new JsonSerializerOptions { + Encoder = JavaScriptEncoder.UnsafeRelaxedJsonEscaping, WriteIndented = true }); Console.WriteLine($"Parsed struct is: {prettyJson}"); @@ -155,7 +157,17 @@ namespace dopt.DeltaBarth.Tests PrettyPrint(res); test.Dispose(); } - + [TestMethod] + public void Umsatzprognose_NoConnectionNeeded_Test() + { + var test = new TPlugin(); + string apiUrlSet = config.apiUrl, user = config.username, password = config.password, database = config.database, mandant = config.mandant; + test.Startup(baseDataPath, apiUrlSet, user, password, database, mandant); + var date = new DateTime(2030, 1, 1, 12, 45, 30); + var res = test.Umsatzprognose(null, date); + PrettyPrint(res); + test.Dispose(); + } [TestMethod] [TestCategory("ActiveAPI")] public void Umsatzprognose_WithCompanyIdWithoutDate_Test() @@ -165,6 +177,7 @@ namespace dopt.DeltaBarth.Tests test.Startup(baseDataPath, apiUrlSet, user, password, database, mandant); var comp_id = 1024; var res = test.Umsatzprognose(comp_id, null); + Assert.AreEqual(4, res.status.code); PrettyPrint(res); test.Dispose(); } @@ -177,6 +190,7 @@ namespace dopt.DeltaBarth.Tests test.Startup(baseDataPath, apiUrlSet, user, password, database, mandant); var date = new DateTime(2030, 1, 1, 12, 45, 30); var res = test.Umsatzprognose(null, date); + Assert.AreEqual(3, res.status.code); PrettyPrint(res); test.Dispose(); } @@ -189,6 +203,7 @@ namespace dopt.DeltaBarth.Tests test.Startup(baseDataPath, apiUrlSet, user, password, database, mandant); var date = new DateTime(2015, 1, 1, 12, 45, 30); var res = test.Umsatzprognose(null, date); + Assert.AreEqual(4, res.status.code); PrettyPrint(res); test.Dispose(); }