public sealed class RunicWindowTestHost<TViewModel> : IDisposable where TViewModel : class Owns one headless Window content session and its generated root attachment. The caller retains ownership of the ViewModel and any dependency injection scope.
Constructors
RunicWindowTestHost
public RunicWindowTestHost(TViewModel viewModel, string rootRoute, Func<IBridgeTransport, WindowContentSession, TViewModel, IDisposable> attach, IRunicViewLocator? viewLocator = null, CancellationToken operationShutdown = default, IRunicModelContext? modelContext = null) Creates a content session for viewModel and attaches its generated root bridge.
Parameters
viewModelThe root ViewModel; the caller keeps ownership.
rootRouteThe generated root route name.
attachThe generated bridge factory.
viewLocatorResolves .NET Views for presented content.
operationShutdownCancels window-owned operations when signalled.
modelContextThe model context the window graph must share, if any.
Remarks
This host uses the system clock and random content ids. The constructor that takes RunicWindowTestHostOptions uses a fake clock and sequential ids.
RunicWindowTestHost
public RunicWindowTestHost(TViewModel viewModel, Func<IBridgeTransport, WindowContentSession, TViewModel, IDisposable> attach, RunicWindowTestHostOptions? options) Creates a content session for viewModel and attaches its generated root bridge. By default the window uses a FakeTimeProvider and sequential ids.
Parameters
viewModelThe root ViewModel; the caller keeps ownership.
attachThe generated bridge factory, such as the
Func<IBridgeTransport, WindowContentSession, TViewModel, IDisposable>that the generatedAddRunicBridges()registers.optionsThe root route, View locator, clock and id source.
RunicWindowTestHost
public RunicWindowTestHost(TViewModel viewModel, Func<IBridgeTransport, WindowContentSession, TViewModel, IDisposable> attach) Creates a content session for viewModel with a FakeTimeProvider and sequential ids, and attaches its generated root bridge.
Parameters
viewModelThe root ViewModel; the caller keeps ownership.
attachThe generated bridge factory.
Properties
RootRoute
public string RootRoute { get; } The generated root route name.
Time
public TimeProvider Time { get; } The window's clock. With the options constructor it is a FakeTimeProvider unless the options supply another clock.
Transport
public InMemoryViewTransport Transport { get; } The in-memory transport that records routes and publications.
ViewModel
public TViewModel ViewModel { get; } The root ViewModel.
Methods
BeginCloseAsync
public ValueTask<BridgeWindowCloseResult> BeginCloseAsync(TimeSpan timeout) Stops admission and waits for accepted Window operations.
Dispose
public void Dispose() Detaches the root bridge and disposes the content session and transport.
Mount
public string Mount(PageReference reference, string token, string? clientKey = null, string? connectionKey = null) Acknowledges that a frontend View was mounted.
Snapshot
public JsonDocument Snapshot(PageReference reference) Reads a generated snapshot from a routed View.
Unmount
public string Unmount(PageReference reference, string token, string? clientKey = null, string? connectionKey = null) Acknowledges that a frontend View was unmounted.
View
public RunicViewDriver<TContent> View<TContent>(PageReference reference) where TContent : class Drives the routes of presented content, such as a reference from a snapshot.