Files
Terminal.Gui/Tests/TerminalGuiFluentTesting/FakeDriver/FakeDriverV2.cs
Tig 18b602e980 Fixes #4243 - ConsoleDriverFacade.CreateClipboard now honors FakeDriver.FakeBehaviors.UseFakeClipboard (#4244)
* updatd ConsoleDriverFacade.CreateClipboard to honor FakeDriver.FakeBehaviors.UseFakeClipboard

* Code cleanup of fake driver v2
2025-09-12 13:32:31 -06:00

58 lines
1.9 KiB
C#

#nullable enable
using System.Collections.Concurrent;
using System.Drawing;
using TerminalGuiFluentTesting;
#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member
namespace Terminal.Gui.Drivers;
/// <summary>
/// Implementation of <see cref="IConsoleDriver"/> that uses fake input/output.
/// This is a lightweight alternative to <see cref="GuiTestContext"/> (if you don't
/// need the entire application main loop running).
/// </summary>
internal class FakeDriverV2 : ConsoleDriverFacade<ConsoleKeyInfo>, IFakeDriverV2
{
internal FakeDriverV2 (
ConcurrentQueue<ConsoleKeyInfo> inputBuffer,
OutputBuffer outputBuffer,
FakeOutput fakeOutput,
Func<DateTime> datetimeFunc,
FakeSizeMonitor sizeMonitor
) :
base (
new NetInputProcessor (inputBuffer),
outputBuffer,
fakeOutput,
new (new AnsiResponseParser (), datetimeFunc),
sizeMonitor)
{
FakeOutput fakeOutput1;
InputBuffer = inputBuffer;
SizeMonitor = sizeMonitor;
OutputBuffer = outputBuffer;
ConsoleOutput = fakeOutput1 = fakeOutput;
SizeChanged += (_, e) =>
{
if (e.Size != null)
{
Size s = e.Size.Value;
fakeOutput1.Size = s;
OutputBuffer.SetWindowSize (s.Width, s.Height);
}
};
}
public void SetBufferSize (int width, int height)
{
SizeMonitor.RaiseSizeChanging (new (width, height));
OutputBuffer.SetWindowSize (width, height);
}
public IConsoleOutput ConsoleOutput { get; }
public ConcurrentQueue<ConsoleKeyInfo> InputBuffer { get; }
public new OutputBuffer OutputBuffer { get; }
public FakeSizeMonitor SizeMonitor { get; }
}