RunicTestNavigationEntry class

Namespace Runic.Application.Testing in Runic.Application.Testing 0.23.0

public static class RunicTestNavigationEntry

Creates navigation entries for unit tests of content that takes a NavigationEntryContext.

Methods

CreateAsync

public static Task<RunicTestNavigationEntry<TContent>> CreateAsync<TContent>(Func<NavigationEntryContext, TContent> create, IServiceProvider? services = null, CancellationToken cancellationToken = default) where TContent : class

Creates a navigator with its own RunicModelContext and one region, and pushes the content that create constructs with its entry's NavigationEntryContext, as the navigator constructs a page: the content is owned by its entry, and its navigation hooks run as in the application.

Type parameters

TContent

The content's type.

Parameters

create

Constructs the content with its entry's context.

services

The navigator's services (RunicNavigatorOptions.Services), which NavigationEntryContext.Services returns, or null for none.

cancellationToken

Cancels the push.

Returns

The entry, current in its region.

Exceptions

InvalidOperationException

The push did not commit, for example because create threw.

Remarks

The entry is pushed with NavigationRegion.PushForResult for an Object result, so NavigationEntryContext.CompleteAsync accepts a value of any type and RunicTestNavigationEntry.Completion reports it.