Table of Contents

Class TestShell

Namespace
ItTiger.TigerCli.Tui.Testing
Assembly
ItTiger.TigerCli.dll
Test shell that runs the real semi-interactive modal loop against a TestTerminal.
public sealed class TestShell : ICliAppShell
Inheritance
TestShell
Implements
Inherited Members

Constructors

TestShell(TestTerminal, int, TigerCliInteractionMode, CultureInfo?, bool)

Creates a test shell over an existing in-memory terminal.
public TestShell(TestTerminal terminal, int viewportHeightPercent = 100, TigerCliInteractionMode interactionMode = TigerCliInteractionMode.SemiInteractive, CultureInfo? culture = null, bool useManualClock = false)

Parameters

terminal TestTerminal
The terminal used to simulate input and capture output.
viewportHeightPercent int
The percentage of terminal height available to the modal viewport.
interactionMode TigerCliInteractionMode
The interaction policy used by the shell.
culture CultureInfo
The UI culture, or null for en-US.
useManualClock bool
Whether timeout tests use a manually advanced clock.

TestShell(int, int, int, TigerCliInteractionMode, CultureInfo?, bool)

Creates a test shell with a new in-memory terminal.
public TestShell(int viewportWidth = 80, int viewportHeight = 24, int viewportHeightPercent = 100, TigerCliInteractionMode interactionMode = TigerCliInteractionMode.SemiInteractive, CultureInfo? culture = null, bool useManualClock = false)

Parameters

viewportWidth int
The simulated terminal width in cells.
viewportHeight int
The simulated terminal height in cells.
viewportHeightPercent int
The percentage of terminal height available to the modal viewport.
interactionMode TigerCliInteractionMode
The interaction policy used by the shell.
culture CultureInfo
The UI culture, or null for en-US.
useManualClock bool
Whether timeout tests use a manually advanced clock.

Properties

Culture

UI culture used to resolve framework-owned localized strings (Yes/No, MultiSelect hint, empty-state labels). Defaults to en-US for shells that do not override it.
public CultureInfo Culture { get; }

Property Value

CultureInfo

InteractionMode

The interaction mode that controls whether prompts may display UI.
public TigerCliInteractionMode InteractionMode { get; }

Property Value

TigerCliInteractionMode

IsFullWindow

True when the shell owns the full terminal window rather than an inline region.
public bool IsFullWindow { get; }

Property Value

bool

Terminal

The in-memory terminal used for simulated input and captured rendering.
public TestTerminal Terminal { get; }

Property Value

TestTerminal

Theme

The theme used by controls hosted in this shell.
public ITheme Theme { get; }

Property Value

ITheme

UsesManualClock

True when this shell was created with useManualClock: true, so the modal inactivity timeout advances only via AdvanceTime(TimeSpan) rather than the wall clock. Use this for deterministic timeout/timer-reset tests.
public bool UsesManualClock { get; }

Property Value

bool

Viewport

The current viewport available for modal rendering.
public Size Viewport { get; }

Property Value

Size

Methods

AdvanceTime(TimeSpan)

Advances the modal inactivity-timeout clock by delta of virtual time. Only the timeout deadline reads this clock; input polling stays real-time, so combine this with Terminal.WaitForInputDrainedAsync to order key presses and time advances deterministically. Requires useManualClock: true.
public void AdvanceTime(TimeSpan delta)

Parameters

delta TimeSpan

RaiseSystemCancellation()

Deterministic seam for process/system cancellation: trips the same system-cancellation token a real Ctrl-C / SIGINT / SIGTERM handler would, so a modal running on this shell completes with SystemCancel without raising a real OS signal.
public void RaiseSystemCancellation()

RunModalAsync(ICliDialog, TimeSpan?, CancellationToken)

Runs a dialog until it produces a result, the optional timeout expires, or the cancellation token is cancelled.
public Task<DialogResult> RunModalAsync(ICliDialog dialog, TimeSpan? timeout = null, CancellationToken ct = default)

Parameters

dialog ICliDialog
timeout TimeSpan?
ct CancellationToken

Returns

Task<DialogResult>

RunModalAsync(ICliDialog, CancellationToken)

Runs a dialog until it produces a result or the cancellation token is cancelled.
public Task<DialogResult> RunModalAsync(ICliDialog dialog, CancellationToken ct = default)

Parameters

dialog ICliDialog
ct CancellationToken

Returns

Task<DialogResult>