mirror of
https://github.com/gui-cs/Terminal.Gui.git
synced 2025-12-26 15:57:56 +01:00
38 lines
1.1 KiB
C#
38 lines
1.1 KiB
C#
using System.Drawing;
|
|
using TerminalGuiFluentTesting;
|
|
|
|
namespace Terminal.Gui.Drivers;
|
|
|
|
/// <summary>
|
|
/// Provides methods to create and manage a fake application for testing purposes.
|
|
/// </summary>
|
|
public class FakeApplicationFactory
|
|
{
|
|
/// <summary>
|
|
/// Creates an initialized fake application which will be cleaned up when result object
|
|
/// is disposed.
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
public IDisposable SetupFakeApplication ()
|
|
{
|
|
CancellationTokenSource hardStopTokenSource = new CancellationTokenSource ();
|
|
FakeInput fakeInput = new FakeInput ();
|
|
fakeInput.ExternalCancellationTokenSource = hardStopTokenSource;
|
|
FakeOutput output = new ();
|
|
output.SetSize (80, 25);
|
|
|
|
IApplication origApp = ApplicationImpl.Instance;
|
|
|
|
SizeMonitorImpl sizeMonitor = new (output);
|
|
|
|
ApplicationImpl impl = new (new FakeComponentFactory (fakeInput, output, sizeMonitor));
|
|
|
|
ApplicationImpl.ChangeInstance (impl);
|
|
|
|
// Initialize with a fake driver
|
|
impl.Init (null, "fake");
|
|
|
|
return new FakeApplicationLifecycle (origApp, hardStopTokenSource);
|
|
}
|
|
}
|