Skip to content

CommandExecution

Result for one executed command within a simulated session.

public sealed class CommandExecution

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>()
  • T: The type the result is expected to have.

T - The typed result.

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>()
  • T: The type to deserialize the output into.

T - The deserialized value.

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)
  • T: The type the result is expected to have.
  • result (T): The typed result when this returns true.

bool - true when the result was available as T.

The command line as it was handed to RunCommandAsync(string, CancellationToken), before tokenization and before any prefilled answers were appended.

public string CommandText { get; }

string

When the command finished, in UTC.

public DateTimeOffset CompletedAtUtc { get; }

DateTimeOffset

How long the command took, measured across the whole execution.

public TimeSpan Duration { get; }

TimeSpan

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; }

int

The semantic interaction events the command raised — statuses, notices, warnings, problems — in the order they were observed.

public IReadOnlyList<ReplInteractionEvent> InteractionEvents { get; }

IReadOnlyList<ReplInteractionEvent>

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; }

ReplExecutionOutcomeKind

Everything the command wrote, with ANSI escape sequences stripped unless NormalizeAnsi was turned off.

public string OutputText { get; }

string

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; }

object

When the command started, in UTC.

public DateTimeOffset StartedAtUtc { get; }

DateTimeOffset

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; }

IReadOnlyList<CommandEvent>