RunicStateTracker<TModel> class

Namespace Runic.Application.Testing · Runic.Application.Testing 0.7.0-preview.5

public sealed class RunicStateTracker<TModel> where TModel : class

Follows one route's state the way the generated client does: it starts from a snapshot, replaces it with newer full states, applies collection deltas against their base revision while checking row keys, and records failure notices. A frame the client could not apply throws, so a test fails where the browser would have had to recover.

Remarks

A tracker takes its route's frames from the host, so do not also call RunicViewDriver.TakePublications for the same route.

Properties

Changes

public IReadOnlyList<RunicCollectionChange> Changes { get; }

The collection changes applied so far, in order.

Deltas

public int Deltas { get; }

How many delta frames were applied.

Failures

public IReadOnlyList<RunicViewPublication> Failures { get; }

The failure notices received so far.

FullStates

public int FullStates { get; }

How many full states replaced the tracked state.

Revision

public long Revision { get; }

The revision of the tracked state.

State

public RunicViewState<TModel> State { get; }

The tracked state.

Methods

Apply

public int Apply()

Applies the frames pushed since the last call and returns how many arrived.

Exceptions

InvalidOperationException

A delta does not continue the tracked revision or its rows.

Verify

public void Verify()

Checks that the tracked state equals a fresh snapshot, apart from revision and field versions: the frames converged on the state .NET holds.

Exceptions

InvalidOperationException

They differ.

WaitUntilAsync

public ValueTask<RunicViewState<TModel>> WaitUntilAsync(Func<RunicViewState<TModel>, bool> predicate, TimeSpan? timeout = null, CancellationToken cancellationToken = default)

Applies frames as they arrive until predicate holds for the tracked state.

Parameters

predicate

The condition to wait for.

timeout

Real time to wait; defaults to the host's publication timeout.

cancellationToken

Stops waiting.

Exceptions

TimeoutException

The condition did not hold in time.