using System.Drawing;
using TerminalGuiFluentTesting;
namespace Terminal.Gui.Drivers;
///
/// Provides methods to create and manage a fake application for testing purposes.
///
public class FakeApplicationFactory
{
///
/// Creates an initialized fake application which will be cleaned up when result object
/// is disposed.
///
///
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);
}
}