Skip to content
ConsoleMonster

API Reference

Class

ScriptedInput

Namespace ConsoleMonster.Input
Assembly ConsoleMonster
Implements
IInputSource IDisposable
Modifiers sealed

Input from a script, for tests, demos and recordings: Down Down Space "ad.evotec" Enter. key names as accepts them (Ctrl+K, Shift+Tab, F2, ?); Down*3 repeats a key; quoted text ("text" or 'text') types each character; paste:"text" pastes; resize:80x24 resizes; wait:250 pauses (milliseconds). Reading past the end throws InputClosedException, so a test whose script is too short fails instead of hanging.

Inheritance

  • Object
  • ScriptedInput

Usage

Explore 1 API references to this type

This type appears in these public API surfaces even when no hand-authored example is attached directly to the page.

Returned or exposed by 1

Constructors

ScriptedInput 2 overloads
public ScriptedInput(String script) #

Creates a scripted source.

Parameters

script System.String requiredposition: 0
The script.
public ScriptedInput(IEnumerable<InputEvent> events) #

Creates a scripted source from events.

Parameters

events System.Collections.Generic.IEnumerable<ConsoleMonster.Input.InputEvent> requiredposition: 0
The events.

Methods

public Void Append(String script) #
Returns: Void

Appends events to the script.

Parameters

script System.String requiredposition: 0
More script.
public Void Dispose() #
Returns: Void

Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.

public static IReadOnlyList<InputEvent> ParseEvents(String script) #
Returns: IReadOnlyList<InputEvent>

Parses a script into events (pauses are dropped).

Parameters

script System.String requiredposition: 0
The script.

Returns

The events.

public InputEvent? Read(TimeSpan timeout, CancellationToken cancellationToken) #
Returns: InputEvent?

Waits up to timeout for the next event.

Parameters

timeout System.TimeSpan requiredposition: 0
The longest wait; TimeSpan.Zero polls.
cancellationToken System.Threading.CancellationToken requiredposition: 1
Cancels the wait with OperationCanceledException.

Returns

The event, or null when the timeout passed without input.

Exceptions

Properties

public String Name { get; } #

A short description for diagnostics, for example windows console (ReadConsoleInputW).

public Int32 Remaining { get; } #

How many events remain.

public Boolean RealTime { get; set; } #

Whether pauses (wait:) really sleep. Off by default so tests run instantly; demos turn it on.

public Boolean Paced { get; set; } #

When true, a read that does not wait (zero timeout) returns null, so a reader that drains bursts draws a frame after every scripted event (golden tests of each step).

public Boolean EndsQuietly { get; set; } #

When true, reading past the end returns null (a timeout) instead of throwing.