TestConsole Class
A testable console.
public sealed class TestConsole : IAnsiConsole, IDisposable
- Namespace
- Spectre
.Console .Testing - Interfaces
-
- IAnsiConsole
- IDisposable
Constructors
-
TestConsole
() -
Initializes a new instance of the
TestConsole
class.
Properties
- IAnsiConsoleCursor Cursor
- Gets the console cursor.
- bool EmitAnsiSequences
- Gets or sets a value indicating whether or not VT/ANSI sequences should be emitted to the console.
- IExclusivityMode ExclusivityMode
- Gets the exclusivity mode.
- TestConsoleInput Input
- Gets the console input.
- IReadOnlyList<string> Lines
- Gets the console output lines.
- string Output
- Gets the console output.
- RenderPipeline Pipeline
- Gets the render pipeline.
- Profile Profile
- Gets the console profile.
Methods
-
void Clear
(bool) - Clears the console.
-
void Dispose
() -
void Write
(IRenderable) -
Writes a
IRenderable
to the console.
Extension Methods
-
void AlternateScreen
(Action) - Switches to an alternate screen buffer if the terminal supports it.
-
T Ask
<T> (string, CultureInfo) - Displays a prompt to the user.
-
T Ask
<T> (string) - Displays a prompt to the user.
-
Task<T> AskAsync
<T> (string, CancellationToken) - Displays a prompt to the user.
-
Task<T> AskAsync
<T> (string, CultureInfo, CancellationToken) - Displays a prompt to the user.
-
void Clear
() - Clears the console.
-
TestConsole Colors
(ColorSystem) - Sets the console's color system.
-
bool Confirm
(string, bool) - Displays a prompt with two choices, yes or no.
-
Task<bool> ConfirmAsync
(string, bool, CancellationToken) - Displays a prompt with two choices, yes or no.
-
Recorder CreateRecorder
() - Creates a recorder for the specified console.
-
TestConsole EmitAnsiSequences
() - Turns on emitting of VT/ANSI sequences.
-
TestConsole Height
(int) - Sets the console height.
-
TestConsole Interactive
() - Makes the console interactive.
-
LiveDisplay Live
(IRenderable) -
Creates a new
LiveDisplay
instance for the console. -
void Markup
(IFormatProvider, string, object[]) - Writes the specified markup to the console.
-
void Markup
(string, object[]) - Writes the specified markup to the console.
-
void Markup
(string) - Writes the specified markup to the console.
-
void MarkupInterpolated
(FormattableString) -
Writes the specified markup to the console.
All interpolation holes which contain a string are automatically escaped so you must not call
EscapeMarkup(string)
. -
void MarkupInterpolated
(IFormatProvider, FormattableString) -
Writes the specified markup to the console.
All interpolation holes which contain a string are automatically escaped so you must not call
EscapeMarkup(string)
. -
void MarkupLine
(IFormatProvider, string, object[]) - Writes the specified markup, followed by the current line terminator, to the console.
-
void MarkupLine
(string, object[]) - Writes the specified markup, followed by the current line terminator, to the console.
-
void MarkupLine
(string) - Writes the specified markup, followed by the current line terminator, to the console.
-
void Markup
Line Interpolated (FormattableString) -
Writes the specified markup, followed by the current line terminator, to the console.
All interpolation holes which contain a string are automatically escaped so you must not call
EscapeMarkup(string)
. -
void Markup
Line Interpolated (IFormatProvider, FormattableString) -
Writes the specified markup, followed by the current line terminator, to the console.
All interpolation holes which contain a string are automatically escaped so you must not call
EscapeMarkup(string)
. -
Progress Progress
() -
Creates a new
Progress(IAnsiConsole)
instance for the console. -
T Prompt
<T> (IPrompt <T> ) - Displays a prompt to the user.
-
Task<T> PromptAsync
<T> (IPrompt <T> , CancellationToken) - Displays a prompt to the user.
-
void Render
(IRenderable) - Renders the specified object to the console.
-
T RunExclusive
<T> (Func <T> ) - Runs the specified function in exclusive mode.
-
Task<T> RunExclusive
<T> (Func <Task <T> > ) - Runs the specified function in exclusive mode asynchronously.
-
TestConsole Size
(Size) - Sets the console size.
-
Status Status
() -
Creates a new
Status(IAnsiConsole)
instance for the console. -
TestConsole SupportsAnsi
(bool) - Sets whether or not ANSI is supported.
-
string ToAnsi
(IRenderable) -
Gets the VT/ANSI control code sequence for a
IRenderable
. -
TestConsole Width
(int) - Sets the console width.
-
void Write
(string, Style) - Writes the specified string value to the console.
-
void Write
(string) - Writes the specified string value to the console.
-
void WriteAnsi
(string) - Writes a VT/Ansi control code sequence to the console (if supported).
-
void WriteException
(Exception, ExceptionFormats) - Writes an exception to the console.
-
void WriteException
(Exception, ExceptionSettings) - Writes an exception to the console.
-
void WriteLine
(string, Style) - Writes the specified string value, followed by the current line terminator, to the console.
-
void WriteLine
(string) - Writes the specified string value, followed by the current line terminator, to the console.
-
void WriteLine
() - Writes an empty line to the console.