ReplTestHost
In-memory orchestrator for opening and coordinating multiple REPL test sessions.
- Kind:
Class - Namespace: Repl.Testing
- Assembly:
Repl.Testing - Source: src/Repl.Testing/ReplTestHost.cs
Signature
Section titled “Signature”public sealed class ReplTestHost : IAsyncDisposableInheritance
Section titled “Inheritance”Implements
Section titled “Implements”Methods
Section titled “Methods”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)Parameters
Section titled “Parameters”appFactory(Func<ReplApp>): Builds the application under test.configure(Action<ReplScenarioOptions>): Adjusts the scenario options shared by every session this host opens.
Returns
Section titled “Returns”ReplTestHost - A host ready to open sessions.
DisposeAsync()
Section titled “DisposeAsync()”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()Returns
Section titled “Returns”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)Parameters
Section titled “Parameters”descriptor(SessionDescriptor): Describes the simulated transport, terminal and prefilled answers. A default descriptor is used when omitted.cancellationToken(CancellationToken): Cancels opening the session.
Returns
Section titled “Returns”ValueTask<ReplSessionHandle> - A handle for running commands in the new session.
QuerySessionsAsync(CancellationToken)
Section titled “QuerySessionsAsync(CancellationToken)”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)Parameters
Section titled “Parameters”cancellationToken(CancellationToken): Cancels the query.
Returns
Section titled “Returns”ValueTask<IReadOnlyList<SessionSnapshot>> - One snapshot per open session.
WaitForDeferredCleanupAsync()
Section titled “WaitForDeferredCleanupAsync()”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()