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); SizeMonitorImpl sizeMonitor = new (output); ApplicationImpl impl = new (new FakeComponentFactory (fakeInput, output, sizeMonitor)); ApplicationImpl.SetInstance (impl); // Initialize with a fake driver impl.Init ("fake"); return new FakeApplicationLifecycle (impl, hardStopTokenSource); } }