CommandExecution
Result for one executed command within a simulated session.
- Kind:
Class - Namespace: Repl.Testing
- Assembly:
Repl.Testing - Source: src/Repl.Testing/CommandExecution.cs
Signature
Section titled “Signature”public sealed class CommandExecutionInheritance
Section titled “Inheritance”Methods
Section titled “Methods”GetResult<T>()
Section titled “GetResult<T>()”Reads ResultObject as T, failing the test outright when the command produced no result or produced a different type. Reads through to the payload as TryGetResult<T>(out T) does.
public T GetResult<T>()Type Parameters
Section titled “Type Parameters”T: The type the result is expected to have.
Returns
Section titled “Returns”T - The typed result.
ReadJson<T>()
Section titled “ReadJson<T>()”Deserializes OutputText as JSON. Asserts on what the command actually rendered, so
it needs the command to have produced JSON — typically through --output:json.
[RequiresUnreferencedCode("JSON deserialization of arbitrary T may require preserved metadata when trimming.")]public T ReadJson<T>()Type Parameters
Section titled “Type Parameters”T: The type to deserialize the output into.
Returns
Section titled “Returns”T - The deserialized value.
TryGetResult<T>(out T?)
Section titled “TryGetResult<T>(out T?)”Reads ResultObject as T, reporting failure instead of throwing when the command produced no result or produced a different type. A result that carries an outcome of its own (IExitResult, ICompletedWithFailuresResult) is read through to its payload when it is not itself a T.
public bool TryGetResult<T>(out T? result)Type Parameters
Section titled “Type Parameters”T: The type the result is expected to have.
Parameters
Section titled “Parameters”result(T): The typed result when this returns true.
Returns
Section titled “Returns”bool - true when the result was available as T.
Properties
Section titled “Properties”CommandText
Section titled “CommandText”The command line as it was handed to RunCommandAsync(string, CancellationToken), before tokenization and before any prefilled answers were appended.
public string CommandText { get; }Returns
Section titled “Returns”CompletedAtUtc
Section titled “CompletedAtUtc”When the command finished, in UTC.
public DateTimeOffset CompletedAtUtc { get; }Returns
Section titled “Returns”Duration
Section titled “Duration”How long the command took, measured across the whole execution.
public TimeSpan Duration { get; }Returns
Section titled “Returns”ExitCode
Section titled “ExitCode”The process-style status the run resolved to, through the application’s own ExitCodes policy rather than a value this toolkit chooses.
public int ExitCode { get; }Returns
Section titled “Returns”InteractionEvents
Section titled “InteractionEvents”The semantic interaction events the command raised — statuses, notices, warnings, problems — in the order they were observed.
public IReadOnlyList<ReplInteractionEvent> InteractionEvents { get; }Returns
Section titled “Returns”IReadOnlyList<ReplInteractionEvent>
OutcomeKind
Section titled “OutcomeKind”How the run ended — a success, a run that completed with failures, a refusal, a crash — which ExitCode alone cannot always tell apart.
public ReplExecutionOutcomeKind OutcomeKind { get; }Returns
Section titled “Returns”OutputText
Section titled “OutputText”Everything the command wrote, with ANSI escape sequences stripped unless NormalizeAnsi was turned off.
public string OutputText { get; }Returns
Section titled “Returns”ResultObject
Section titled “ResultObject”The normalized handler result, or null when the command produced none. Prefer TryGetResult<T>(out T) or GetResult<T>() over casting this yourself.
public object? ResultObject { get; }Returns
Section titled “Returns”StartedAtUtc
Section titled “StartedAtUtc”When the command started, in UTC.
public DateTimeOffset StartedAtUtc { get; }Returns
Section titled “Returns”TimelineEvents
Section titled “TimelineEvents”The command’s events: everything it wrote as a single event, then each interaction it raised in the order it was observed, then the result it produced.
The output event is a single aggregate of everything the command wrote, and it always comes first — it is not interleaved with the interactions. An assertion that a particular line was written before or after a given interaction is asserting this shape, not an observed chronology.
public IReadOnlyList<CommandEvent> TimelineEvents { get; }Returns
Section titled “Returns”IReadOnlyList<CommandEvent>