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.
45 lines
1.6 KiB
C#
45 lines
1.6 KiB
C#
|
|
namespace TerminalGuiFluentTesting;
|
|
|
|
/// <summary>
|
|
/// Entry point to fluent assertions.
|
|
/// </summary>
|
|
public static class With
|
|
{
|
|
/// <summary>
|
|
/// Entrypoint to fluent assertions
|
|
/// </summary>
|
|
/// <param name="width"></param>
|
|
/// <param name="height"></param>
|
|
/// <param name="testDriver">Which v2 testDriver to use for the test</param>
|
|
/// <param name="logWriter"></param>
|
|
/// <returns></returns>
|
|
public static GuiTestContext A<T> (int width, int height, TestDriver testDriver, TextWriter? logWriter = null) where T : Toplevel, new()
|
|
{
|
|
return new (() => new T ()
|
|
{
|
|
//Id = $"{typeof (T).Name}"
|
|
}, width, height, testDriver, logWriter, Timeout);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Overload that takes a function to create instance <paramref name="toplevelFactory"/> after application is initialized.
|
|
/// </summary>
|
|
/// <param name="toplevelFactory"></param>
|
|
/// <param name="width"></param>
|
|
/// <param name="height"></param>
|
|
/// <param name="testDriver"></param>
|
|
/// <param name="logWriter"></param>
|
|
/// <returns></returns>
|
|
public static GuiTestContext A (Func<Toplevel> toplevelFactory, int width, int height, TestDriver testDriver, TextWriter? logWriter = null)
|
|
{
|
|
return new (toplevelFactory, width, height, testDriver, logWriter, Timeout);
|
|
}
|
|
/// <summary>
|
|
/// The global timeout to allow for any given application to run for before shutting down.
|
|
/// </summary>
|
|
public static TimeSpan Timeout { get; set; } = TimeSpan.FromSeconds (30);
|
|
|
|
|
|
}
|