Stabilize BizTalk inventory collection and diagnostics
Build und Test / build (push) Has been cancelled

This commit is contained in:
2026-07-28 10:55:57 +02:00
parent 439427cc17
commit d1e10920c9
11 changed files with 1008 additions and 172 deletions
@@ -2,6 +2,7 @@ using System;
using System.IO;
using System.IO.Compression;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Xml.Linq;
using BizTalkSapEnvironmentInventory.Collectors;
@@ -23,6 +24,7 @@ namespace BizTalkSapEnvironmentInventory.Infrastructure
{
TestSanitizer();
TestBindingParser();
TestLoggerDiagnostics();
TestDocxPackage();
}
@@ -236,6 +238,47 @@ namespace BizTalkSapEnvironmentInventory.Infrastructure
}
}
private static void TestLoggerDiagnostics()
{
var directory = CreateTemporaryDirectory();
var path = Path.Combine(directory, "diagnostics.log");
try
{
var exception = new TargetInvocationException(
new InvalidOperationException("Innerer Diagnosefehler"));
using (var logger = new ConsoleFileLogger(path))
{
var originalOutput = Console.Out;
try
{
// Die absichtlich erzeugte Testausnahme soll den Self-Test
// auf der Konsole nicht wie einen echten Laufzeitfehler aussehen lassen.
Console.SetOut(TextWriter.Null);
logger.Exception("Self-Test-Diagnose", exception);
}
finally
{
Console.SetOut(originalOutput);
}
}
var log = File.ReadAllText(path);
Assert(
log.Contains(typeof(TargetInvocationException).FullName),
"Logger dokumentierte die Reflection-Ausnahme nicht.");
Assert(
log.Contains(typeof(InvalidOperationException).FullName),
"Logger dokumentierte die innere Ausnahme nicht.");
Assert(
log.Contains("HRESULT=0x"),
"Logger dokumentierte den HRESULT nicht.");
}
finally
{
DeleteDirectory(directory);
}
}
private static void AssertPackageNamespaces(ZipArchive archive)
{
var contentTypes = LoadEntryXml(archive, "[Content_Types].xml");