API Reference
TestTerminal
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) #InteractiveOptionsOptions 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
- The keys (see TestTerminal.Keys).
- capture ConsoleMonster.Interactive.ScreenCapture
- Where the screens go.
- glyphs ConsoleMonster.Capabilities.GlyphTier = Full
- The glyph tier.
Returns
The options.
public static ScriptedInput Keys(String script) #ScriptedInputScripted 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
- 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) #TerminalProfileA fixed terminal profile: no detection, the given size, tier, depth and culture (invariant by default).
Parameters
- width System.Int32 = 80
- Width in cells.
- height System.Int32 = 24
- Height in cells.
- glyphs ConsoleMonster.Capabilities.GlyphTier = Full
- The glyph tier.
- colors ConsoleMonster.Capabilities.ColorDepth = None
- The colour depth (none by default, so text is plain).
- culture System.Globalization.CultureInfo? = null
- 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) #CellBufferRenders a widget into cells: as tall as it measures, or exactly height rows.
Parameters
- widget ConsoleMonster.Layout.IWidget
- The widget.
- width System.Int32 = 80
- Width in cells.
- height System.Int32 = 0
- Height in cells; 0 measures the widget.
- glyphs ConsoleMonster.Capabilities.GlyphTier = Full
- The glyph tier.
- culture System.Globalization.CultureInfo? = null
- The culture; null for the invariant culture.
- theme ConsoleMonster.Styling.ITheme? = null
- 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) #StringRenders a widget to plain text: rows joined with \n, trailing spaces trimmed.
Parameters
- widget ConsoleMonster.Layout.IWidget
- The widget.
- width System.Int32 = 80
- Width in cells.
- height System.Int32 = 0
- Height in cells; 0 measures the widget.
- glyphs ConsoleMonster.Capabilities.GlyphTier = Full
- The glyph tier.
- culture System.Globalization.CultureInfo? = null
- 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) #RecordingTargetAn 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
- Width in cells.
- height System.Int32 = 24
- Height in cells (the screen size for prompts).
- glyphs ConsoleMonster.Capabilities.GlyphTier = Full
- The glyph tier.
- colors ConsoleMonster.Capabilities.ColorDepth = None
- The colour depth (none by default, so the text is plain).
- culture System.Globalization.CultureInfo? = null
- The culture for numbers, dates and labels; null for the invariant culture (English labels).
- keys System.String? = null
- Scripted keys for prompts (see TestTerminal.Keys), or null so prompts use their defaults.
Returns
The target.
Inherited Methods
public virtual Boolean Equals(Object? obj) #BooleanParameters
- obj Object?