TestConsoleInput Class

Represents a testable console input mechanism.
public sealed class TestConsoleInput : IAnsiConsoleInput

Constructors

TestConsoleInput()
Initializes a new instance of the TestConsoleInput class.

Methods

bool IsKeyAvailable()
Gets a value indicating whether or not there is a key available.
void PushCharacter(char)
Pushes the specified character to the input queue.
void PushKey(ConsoleKey)
Pushes the specified key to the input queue.
void PushKey(ConsoleKeyInfo)
Pushes the specified key to the input queue.
void PushText(string)
Pushes the specified text to the input queue.
void PushTextWithEnter(string)
Pushes the specified text followed by 'Enter' to the input queue.
ConsoleKeyInfo? ReadKey(bool)
Reads a key from the console.
Task<ConsoleKeyInfo?> ReadKeyAsync(bool, CancellationToken)
Reads a key from the console.

Extension Methods

T And<TestConsoleInput>(Action<TestConsoleInput>)
Performs the specified action on the given object and then returns the object. Useful for fluent testing patterns where additional assertions or operations are chained together in a readable manner.