mirror of
https://github.com/ajisaacs/OpenNest.git
synced 2026-10-06 18:32:11 -04:00
The new windows-desktop CI job surfaced several tests that had never actually run on Windows: - SeparatorPenLifetimeTests expected Control.Disposed to fire only once; current WinForms re-fires it on every Dispose() call. - EditNestFocusTraversalTests assumed the Plates tab was selected by default, which stopped being true once Drawings became the landing tab; select it explicitly before asserting focus. - NestReportExportTests asserted an exact plate count that ignored PlateManager's trailing sentinel plate, and didn't expect the nest name in the busy-export message. - AtomicReportFileTests only expected IOException when replacing a directory target; Windows raises UnauthorizedAccessException instead, which callers already treat the same way. Also register a ThreadException handler so an exception inside a WndProc callback fails the test normally instead of popping a modal dialog that blocks the desktop. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
23 lines
1.0 KiB
C#
23 lines
1.0 KiB
C#
using System.Runtime.CompilerServices;
|
|
using System.Windows.Forms;
|
|
|
|
namespace OpenNest.WinForms.Tests;
|
|
|
|
internal static class TestAssemblySetup
|
|
{
|
|
// SetUnhandledExceptionMode only changes which *default* dialog style WinForms would
|
|
// show; it still shows one. A registered ThreadException handler is what actually
|
|
// suppresses it (WinForms always prefers the handler over the default dialog), which
|
|
// matters here because none of our tests call Application.Run() to install one.
|
|
// Without this, an exception thrown inside a WndProc callback (e.g. a DataGridView
|
|
// commit failure during Show()) pops a modal ThreadExceptionDialog that blocks the
|
|
// desktop until someone dismisses it by hand, instead of failing the test normally.
|
|
[ModuleInitializer]
|
|
internal static void Initialize()
|
|
{
|
|
Application.SetUnhandledExceptionMode(UnhandledExceptionMode.ThrowException);
|
|
Application.ThreadException += (_, e) =>
|
|
Console.Error.WriteLine($"Suppressed ThreadExceptionDialog: {e.Exception}");
|
|
}
|
|
}
|