mirror of
https://github.com/gui-cs/Terminal.Gui.git
synced 2025-12-26 15:57:56 +01:00
Remove dependency on fluent assertions and fix folder paths
This commit is contained in:
34
TerminalGuiFluentTesting/FakeInput.cs
Normal file
34
TerminalGuiFluentTesting/FakeInput.cs
Normal file
@@ -0,0 +1,34 @@
|
||||
using System.Collections.Concurrent;
|
||||
using Terminal.Gui;
|
||||
|
||||
namespace TerminalGuiFluentTesting;
|
||||
|
||||
internal class FakeInput<T> : IConsoleInput<T>
|
||||
{
|
||||
private readonly CancellationToken _hardStopToken;
|
||||
|
||||
private readonly CancellationTokenSource _timeoutCts;
|
||||
|
||||
public FakeInput (CancellationToken hardStopToken)
|
||||
{
|
||||
_hardStopToken = hardStopToken;
|
||||
|
||||
// Create a timeout-based cancellation token too to prevent tests ever fully hanging
|
||||
_timeoutCts = new (With.Timeout);
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public void Dispose () { }
|
||||
|
||||
/// <inheritdoc/>
|
||||
public void Initialize (ConcurrentQueue<T> inputBuffer) { InputBuffer = inputBuffer; }
|
||||
|
||||
public ConcurrentQueue<T> InputBuffer { get; set; }
|
||||
|
||||
/// <inheritdoc/>
|
||||
public void Run (CancellationToken token)
|
||||
{
|
||||
// Blocks until either the token or the hardStopToken is cancelled.
|
||||
WaitHandle.WaitAny (new [] { token.WaitHandle, _hardStopToken.WaitHandle, _timeoutCts.Token.WaitHandle });
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user