Skip to content

ReplTestHost

In-memory orchestrator for opening and coordinating multiple REPL test sessions.

public sealed class ReplTestHost : IAsyncDisposable

Create(Func<ReplApp>, Action<ReplScenarioOptions>?)

Section titled “Create(Func<ReplApp>, Action<ReplScenarioOptions>?)”

Creates a host over an application factory. The factory is invoked once per session, so each session gets its own ReplApp and service provider.

public static ReplTestHost Create(Func<ReplApp> appFactory, Action<ReplScenarioOptions>? configure = null)
  • appFactory (Func<ReplApp>): Builds the application under test.
  • configure (Action<ReplScenarioOptions>): Adjusts the scenario options shared by every session this host opens.

ReplTestHost - A host ready to open sessions.

Disposes every session this host still owns, then the root IServiceProvider of every distinct ReplApp a session was opened against. Disposing twice is a no-op.

public ValueTask DisposeAsync()

ValueTask

OpenSessionAsync(SessionDescriptor?, CancellationToken)

Section titled “OpenSessionAsync(SessionDescriptor?, CancellationToken)”

Opens a session. Sessions are independent and may run concurrently: application state persists across the commands of one session and is not shared with another.

public ValueTask<ReplSessionHandle> OpenSessionAsync(SessionDescriptor? descriptor = null, CancellationToken cancellationToken = default)
  • descriptor (SessionDescriptor): Describes the simulated transport, terminal and prefilled answers. A default descriptor is used when omitted.
  • cancellationToken (CancellationToken): Cancels opening the session.

ValueTask<ReplSessionHandle> - A handle for running commands in the new session.

Snapshots every session currently open on this host, ordered by session id so an assertion does not depend on the order they were opened in.

public ValueTask<IReadOnlyList<SessionSnapshot>> QuerySessionsAsync(CancellationToken cancellationToken = default)

ValueTask<IReadOnlyList<SessionSnapshot>> - One snapshot per open session.

Awaits every app-root disposal DisposeAsync() scheduled rather than performed directly, because a session’s command was still running at the time it was called.

public Task WaitForDeferredCleanupAsync()

Task