FakeDriverBase.cs 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. namespace UnitTests;
  2. /// <summary>
  3. /// Enables tests to create a FakeDriver for testing purposes.
  4. /// </summary>
  5. [Collection ("Global Test Setup")]
  6. public abstract class FakeDriverBase : IDisposable
  7. {
  8. /// <summary>
  9. /// Creates a new FakeDriver instance with the specified buffer size.
  10. /// This is a convenience method for tests that need to use Draw() and DriverAssert
  11. /// without relying on Application.Driver.
  12. /// </summary>
  13. /// <param name="width">Width of the driver buffer</param>
  14. /// <param name="height">Height of the driver buffer</param>
  15. /// <returns>A configured IFakeDriver instance</returns>
  16. protected static IDriver CreateFakeDriver (int width = 80, int height = 25)
  17. {
  18. var output = new FakeOutput ();
  19. DriverImpl driver = new (
  20. new FakeInputProcessor (null),
  21. new OutputBufferImpl (),
  22. output,
  23. new AnsiRequestScheduler (new AnsiResponseParser ()),
  24. new SizeMonitorImpl (output));
  25. driver.SetScreenSize (width, height);
  26. return driver;
  27. }
  28. /// <inheritdoc />
  29. public void Dispose ()
  30. {
  31. Application.ResetState (true);
  32. }
  33. }