assert no pipeline crash if API server is not available, fix #8

This commit is contained in:
Florian Förster 2025-04-03 13:05:40 +02:00
parent e44a4b4958
commit e298c2ce51

View File

@ -4,6 +4,7 @@ using static Microsoft.ApplicationInsights.MetricDimensionNames.TelemetryContext
namespace dopt.DeltaBarth.Tests namespace dopt.DeltaBarth.Tests
{ {
using System.Text.Encodings.Web;
using Microsoft.Extensions.Configuration; using Microsoft.Extensions.Configuration;
internal class Config internal class Config
{ {
@ -65,6 +66,7 @@ namespace dopt.DeltaBarth.Tests
{ {
string prettyJson = JsonSerializer.Serialize(toSerialise, new JsonSerializerOptions string prettyJson = JsonSerializer.Serialize(toSerialise, new JsonSerializerOptions
{ {
Encoder = JavaScriptEncoder.UnsafeRelaxedJsonEscaping,
WriteIndented = true WriteIndented = true
}); });
Console.WriteLine($"Parsed struct is: {prettyJson}"); Console.WriteLine($"Parsed struct is: {prettyJson}");
@ -155,7 +157,17 @@ namespace dopt.DeltaBarth.Tests
PrettyPrint(res); PrettyPrint(res);
test.Dispose(); 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] [TestMethod]
[TestCategory("ActiveAPI")] [TestCategory("ActiveAPI")]
public void Umsatzprognose_WithCompanyIdWithoutDate_Test() public void Umsatzprognose_WithCompanyIdWithoutDate_Test()
@ -165,6 +177,7 @@ namespace dopt.DeltaBarth.Tests
test.Startup(baseDataPath, apiUrlSet, user, password, database, mandant); test.Startup(baseDataPath, apiUrlSet, user, password, database, mandant);
var comp_id = 1024; var comp_id = 1024;
var res = test.Umsatzprognose(comp_id, null); var res = test.Umsatzprognose(comp_id, null);
Assert.AreEqual(4, res.status.code);
PrettyPrint(res); PrettyPrint(res);
test.Dispose(); test.Dispose();
} }
@ -177,6 +190,7 @@ namespace dopt.DeltaBarth.Tests
test.Startup(baseDataPath, apiUrlSet, user, password, database, mandant); test.Startup(baseDataPath, apiUrlSet, user, password, database, mandant);
var date = new DateTime(2030, 1, 1, 12, 45, 30); var date = new DateTime(2030, 1, 1, 12, 45, 30);
var res = test.Umsatzprognose(null, date); var res = test.Umsatzprognose(null, date);
Assert.AreEqual(3, res.status.code);
PrettyPrint(res); PrettyPrint(res);
test.Dispose(); test.Dispose();
} }
@ -189,6 +203,7 @@ namespace dopt.DeltaBarth.Tests
test.Startup(baseDataPath, apiUrlSet, user, password, database, mandant); test.Startup(baseDataPath, apiUrlSet, user, password, database, mandant);
var date = new DateTime(2015, 1, 1, 12, 45, 30); var date = new DateTime(2015, 1, 1, 12, 45, 30);
var res = test.Umsatzprognose(null, date); var res = test.Umsatzprognose(null, date);
Assert.AreEqual(4, res.status.code);
PrettyPrint(res); PrettyPrint(res);
test.Dispose(); test.Dispose();
} }