Strip out MS-CAB extraction test even further

This will make it so that exceptions are surfaced directly into the test log and cancel right away. It effectively does the same thing as capturing the error log and redirecting it, but with many less steps.
This commit is contained in:
Matt Nadareski
2026-10-26 09:52:32 -04:00
parent 11f9bf9fd9
commit f639f7ac24

View File

@@ -68,16 +68,9 @@ namespace SabreTools.Wrappers.Test
var cabinet = MicrosoftCabinet.Create(File.ReadAllBytes(path), 0);
Assert.NotNull(cabinet);
// Extract catches the exception and only writes it to the console
string outputDirectory = Path.Combine(Path.GetTempPath(), Path.GetRandomFileName());
var originalError = Console.Error;
var error = new StringWriter();
Console.SetError(error);
cabinet.Extract(outputDirectory, includeDebug: true);
Console.SetError(originalError);
// Assert.True shows the whole exception, Assert.Empty cuts it off
Assert.True(error.ToString().Length == 0, error.ToString());
Assert.Equal("Hello, ", File.ReadAllText(Path.Combine(outputDirectory, "a.txt")));
Assert.Equal("World!", File.ReadAllText(Path.Combine(outputDirectory, "b.txt")));
Directory.Delete(outputDirectory, recursive: true);