mirror of
https://github.com/gui-cs/Terminal.Gui.git
synced 2025-12-26 07:47:54 +01:00
Replaced static `Application` references with instance-based `App` context across the codebase. Updated calls to `Application.RequestStop()` and `Application.Screen` to use `App?.RequestStop()` and `App?.Screen` for better encapsulation and flexibility. Refactored test infrastructure to align with the new context, including reintroducing `FakeApplicationFactory` and `FakeApplicationLifecycle` for testing purposes. Improved logging, error handling, and test clarity by adding `logWriter` support and simplifying test setup. Removed redundant or obsolete code, such as `NetSequences` and the old `FakeApplicationFactory` implementation. Updated documentation to reflect the new `IApplication.RequestStop()` usage.
20 lines
594 B
C#
20 lines
594 B
C#
#nullable enable
|
|
namespace Terminal.Gui.Drivers;
|
|
|
|
/// <summary>
|
|
/// Implements a fake application lifecycle for testing purposes. Cleans up the application on dispose by cancelling
|
|
/// the provided <see cref="CancellationTokenSource"/> and shutting down the application.
|
|
/// </summary>
|
|
/// <param name="hardStop"></param>
|
|
internal class FakeApplicationLifecycle (CancellationTokenSource hardStop) : IDisposable
|
|
{
|
|
/// <inheritdoc/>
|
|
public void Dispose ()
|
|
{
|
|
hardStop.Cancel ();
|
|
|
|
Application.TopRunnable?.Dispose ();
|
|
Application.Shutdown ();
|
|
}
|
|
}
|