public sealed class RunicViewDriver<TModel> where TModel : class Calls the generated routes of one TModel presentation by ViewModel member, as the generated TypeScript client does, instead of by raw route name.
Example
var editor = host.Root.View<DocumentViewModel>(vm => vm.Main).View<EditorViewModel>(vm => vm.CurrentPane);
editor.Set(vm => vm.Title, "Groceries").EnsureOk();
(await editor.ExecuteAsync(vm => vm.SaveCommand)).EnsureOk();Properties
Reference
public PageReference? Reference { get; } The content reference this driver presents, or null for the root route.
Route
public string Route { get; } The route prefix: the root name, or content{id} for presented content.
Methods
CanExecute
public bool CanExecute(Expression<Func<TModel, object?>> command, string argumentJson) Asks whether a command with an argument can execute (can{Command}(input)).
ExecuteAsync
public ValueTask<RunicCallReply<TModel>> ExecuteAsync(Expression<Func<TModel, object?>> command, string? argumentJson = null, CancellationToken cancellationToken = default) Executes a command, as the client's {command}(input) does, and waits for an asynchronous command to finish.
Parameters
commandThe command property, such as
vm => vm.SaveCommand.argumentJsonThe command input as wire JSON, for a command with an argument.
cancellationTokenCancels an awaited command, as a closed client connection does.
Remarks
A command that waits on the host's fake clock finishes only after the test advances it: start the call, advance RunicWindowTestHost.Time, then await the call.
Mount
public string Mount(string? token = null, string? clientKey = null, string? connectionKey = null) Acknowledges a browser presentation, as a frontend outlet does when it mounts this View.
Parameters
tokenThe mount token, `{session}:{presentation}`; the host issues `test:mount{n}` when omitted.
clientKeyThe client identity, for tests of several browser clients.
connectionKeyThe connection identity, for tests of a client disconnect.
Returns
The mount token; pass it to RunicViewDriver.Unmount.
NextPublicationAsync
public ValueTask<RunicViewPublication> NextPublicationAsync(TimeSpan? timeout = null, CancellationToken cancellationToken = default) Waits for the next frame pushed to this route.
Parameters
timeoutReal time to wait; defaults to the host's publication timeout.
cancellationTokenStops waiting.
Exceptions
TimeoutExceptionNothing was pushed in time.
Set
public RunicCallReply<TModel> Set<TValue>(Expression<Func<TModel, TValue>> property, TValue value) Calls the generated setter as the client's set{Property}(value) does: an int, bool or non-nullable string property passes its value, and any other scalar property passes wire JSON (an Int64 or decimal as a string, an enum by name, null for a nullable value). Use RunicViewDriver.SetJson for DTOs, lists and unions.
SetJson
public RunicCallReply<TModel> SetJson<TValue>(Expression<Func<TModel, TValue>> property, string wireJson) Calls the generated setter of a property with a value already encoded as wire JSON.
Start
public RunicTestOperation Start(Expression<Func<TModel, object?>> command, string? argumentJson = null, string? requestId = null) Starts an asynchronous command as a recoverable operation (start{Command}()).
Parameters
commandThe command property.
argumentJsonThe command input as wire JSON, for a command with an argument.
requestIdThe idempotency key; the host issues
request{n}when omitted.
TakePublications
public IReadOnlyList<RunicViewPublication> TakePublications() Returns and removes the frames pushed to this route so far.
Track
public RunicStateTracker<TModel> Track() Follows this route's state from a snapshot through its pushed frames, applying collection deltas as the client does and failing on a frame the client could not apply.
Unmount
public string Unmount(string token, string? clientKey = null, string? connectionKey = null) Releases a browser presentation.
View
public RunicViewDriver<TContent> View<TContent>(Expression<Func<TModel, object?>> property) where TContent : class Drives the content that a ViewModel content property presents now.
Type parameters
TContentThe presented ViewModel type, checked against the reference's kind.
Views
public IReadOnlyList<RunicViewDriver<TContent>> Views<TContent>(Expression<Func<TModel, object?>> property) where TContent : class Drives each item that a ViewModel content collection presents now.
Write
public RunicFieldWriteReceipt<TModel> Write<TValue>(Expression<Func<TModel, TValue>> property, TValue value, long? expectedVersion = null) Writes a scalar checked field, encoded as RunicViewDriver.Set encodes JSON values, as the client's write{Property}(value, { requestId, baseline }) does. The baseline is the current value and, unless given, its current version.