QuellCode/CentronERP war nur als Gitlink (Submodul-Referenz auf 79c1142) getrackt, ohne .gitmodules und ohne erreichbares Remote. Der Untersuchungsgegenstand der Versuchsreihe war damit nicht reproduzierbar gesichert: Ein Klon haette ein leeres Verzeichnis erhalten, und die Belege der 3.287 Anforderungen waeren nicht ueberpruefbar gewesen. Umstellung: - Historie nach c:\DEV\CentronERP_git_snapshot_79c1142 ausgelagert (vollstaendig lesbar, enthaelt 79c1142 und Vorgaenger 89ccfd6) - Gitlink aus dem Index entfernt - Dateiinhalt aufgenommen: 24.557 Dateien, rund 333 MB Die verschachtelte .gitignore der Codebasis gilt weiter, Build-Artefakte bleiben ausgeschlossen. Details in Versuche/Versuch_01/_Codebasis-Nachweis.md
100 lines
2.8 KiB
C#
100 lines
2.8 KiB
C#
using System.Diagnostics.CodeAnalysis;
|
|
using System.Text.Json.Nodes;
|
|
using CentronNexus.Configuration.Migrations;
|
|
|
|
namespace CentronNexusTests.Configuration.Migrations;
|
|
|
|
public class MultiWebServiceToSingleWebServiceConfigMigrationTests
|
|
{
|
|
private readonly MultiWebServiceToSingleWebServiceConfigMigration202308181135 _migration = new();
|
|
|
|
[Fact]
|
|
public void Success()
|
|
{
|
|
var input = new JsonObject
|
|
{
|
|
["CentronWebService"] = new JsonObject
|
|
{
|
|
["WebServices"] = new JsonArray
|
|
{
|
|
new JsonObject
|
|
{
|
|
["IsDefault"] = false,
|
|
["Url"] = "https://1.de"
|
|
},
|
|
new JsonObject
|
|
{
|
|
["IsDefault"] = true,
|
|
["Url"] = "https://2.de" // This one should be taken as the Url
|
|
},
|
|
}
|
|
}
|
|
};
|
|
|
|
this.Test(true, input);
|
|
|
|
Assert.Equal("https://2.de", (string?)input["CentronWebService"]?["Url"]); // The default web-service should be in CentronWebService->Url now
|
|
Assert.Null(input["CentronWebService"]?["WebServices"]); // The CentronWebService->WebServices array should be removed
|
|
}
|
|
|
|
[Fact]
|
|
public void Failure_CentronWebService_NotFound()
|
|
{
|
|
var input = new JsonObject
|
|
{
|
|
["Something"] = 12
|
|
// No CentronWebService here, do nothing
|
|
};
|
|
|
|
this.Test(false, input);
|
|
}
|
|
|
|
[Fact]
|
|
public void Failure_WebServices_NotFound()
|
|
{
|
|
var input = new JsonObject
|
|
{
|
|
["CentronWebService"] = new JsonObject
|
|
{
|
|
["Something"] = 12
|
|
// NoWebServices here, do nothing
|
|
}
|
|
};
|
|
|
|
this.Test(false, input);
|
|
}
|
|
|
|
[Fact]
|
|
public void Failure_Url_AlreadyExists()
|
|
{
|
|
var input = new JsonObject
|
|
{
|
|
["CentronWebService"] = new JsonObject
|
|
{
|
|
["Url"] = "https://google.de", // Url already exists, do nothing
|
|
["WebServices"] = new JsonArray
|
|
{
|
|
new JsonObject
|
|
{
|
|
["IsDefault"] = false,
|
|
["Url"] = "https://1.de"
|
|
},
|
|
new JsonObject
|
|
{
|
|
["IsDefault"] = true,
|
|
["Url"] = "https://2.de"
|
|
},
|
|
}
|
|
}
|
|
};
|
|
|
|
this.Test(false, input);
|
|
}
|
|
|
|
private void Test(bool expectedResult, JsonNode input)
|
|
{
|
|
var result = this._migration.TryApplyTo(input);
|
|
Assert.Equal(expectedResult, result);
|
|
}
|
|
}
|