Skip to content
ConsoleMonster

API Reference

Class

TestTerminal

Namespace ConsoleMonster.Testing
Assembly ConsoleMonster
Modifiers static

Helpers for testing console output in any test framework: render a widget at a fixed size, glyph tier, colour depth and culture (so results do not depend on the machine), drive prompts, menus and forms with scripted keys, and capture the screens they draw. Pair with GoldenFile for snapshot tests.

Inheritance

  • Object
  • TestTerminal

Methods

public static InteractiveOptions Interactive(String keys, ScreenCapture capture, GlyphTier glyphs = Full) #
Returns: InteractiveOptions

Options that run a prompt, menu or form against scripted keys and draw into capture (rich mode, dark theme, no colour, invariant culture, the capture's size).

Parameters

keys System.String requiredposition: 0
The keys (see TestTerminal.Keys).
capture ConsoleMonster.Interactive.ScreenCapture requiredposition: 1
Where the screens go.
glyphs ConsoleMonster.Capabilities.GlyphTier = Full optionalposition: 2
The glyph tier.

Returns

The options.

public static ScriptedInput Keys(String script) #
Returns: ScriptedInput

Scripted keys for prompts and menus, for example "Down Down Space Enter", "\"typed text\" Tab", "Ctrl+K paste:'x' wait:200". Paced, so every step draws a frame.

Parameters

script System.String requiredposition: 0
The keys.

Returns

The input source.

public static TerminalProfile Profile(Int32 width = 80, Int32 height = 24, GlyphTier glyphs = Full, ColorDepth colors = None, CultureInfo? culture = null) #
Returns: TerminalProfile

A fixed terminal profile: no detection, the given size, tier, depth and culture (invariant by default).

Parameters

width System.Int32 = 80 optionalposition: 0
Width in cells.
height System.Int32 = 24 optionalposition: 1
Height in cells.
glyphs ConsoleMonster.Capabilities.GlyphTier = Full optionalposition: 2
The glyph tier.
colors ConsoleMonster.Capabilities.ColorDepth = None optionalposition: 3
The colour depth (none by default, so text is plain).
culture System.Globalization.CultureInfo? = null optionalposition: 4
The culture; null for the invariant culture.

Returns

The profile.

public static CellBuffer Render(IWidget widget, Int32 width = 80, Int32 height = 0, GlyphTier glyphs = Full, CultureInfo? culture = null, ITheme? theme = null) #
Returns: CellBuffer

Renders a widget into cells: as tall as it measures, or exactly height rows.

Parameters

widget ConsoleMonster.Layout.IWidget requiredposition: 0
The widget.
width System.Int32 = 80 optionalposition: 1
Width in cells.
height System.Int32 = 0 optionalposition: 2
Height in cells; 0 measures the widget.
glyphs ConsoleMonster.Capabilities.GlyphTier = Full optionalposition: 3
The glyph tier.
culture System.Globalization.CultureInfo? = null optionalposition: 4
The culture; null for the invariant culture.
theme ConsoleMonster.Styling.ITheme? = null optionalposition: 5
The theme; null for the dark theme.

Returns

The cells.

public static String RenderText(IWidget widget, Int32 width = 80, Int32 height = 0, GlyphTier glyphs = Full, CultureInfo? culture = null) #
Returns: String

Renders a widget to plain text: rows joined with \n, trailing spaces trimmed.

Parameters

widget ConsoleMonster.Layout.IWidget requiredposition: 0
The widget.
width System.Int32 = 80 optionalposition: 1
Width in cells.
height System.Int32 = 0 optionalposition: 2
Height in cells; 0 measures the widget.
glyphs ConsoleMonster.Capabilities.GlyphTier = Full optionalposition: 3
The glyph tier.
culture System.Globalization.CultureInfo? = null optionalposition: 4
The culture; null for the invariant culture.

Returns

The text.

public static RecordingTarget Target(Int32 width = 80, Int32 height = 24, GlyphTier glyphs = Full, ColorDepth colors = None, CultureInfo? culture = null, String? keys = null) #
Returns: RecordingTarget

An in-memory target with a fixed profile (append-only output, no detection): pass it to code that takes an ITerminalTarget, or scope the static Terminal methods to it with Terminal.Use. Its RecordingTarget.Text goes to GoldenFile through RecordingTarget.MatchGolden; scripted keys answer prompts, which draw into RecordingTarget.Screens.

Parameters

width System.Int32 = 80 optionalposition: 0
Width in cells.
height System.Int32 = 24 optionalposition: 1
Height in cells (the screen size for prompts).
glyphs ConsoleMonster.Capabilities.GlyphTier = Full optionalposition: 2
The glyph tier.
colors ConsoleMonster.Capabilities.ColorDepth = None optionalposition: 3
The colour depth (none by default, so the text is plain).
culture System.Globalization.CultureInfo? = null optionalposition: 4
The culture for numbers, dates and labels; null for the invariant culture (English labels).
keys System.String? = null optionalposition: 5
Scripted keys for prompts (see TestTerminal.Keys), or null so prompts use their defaults.

Returns

The target.