Table of Contents

Interface ITestRenderer

Namespace
Bunit.Rendering
Assembly
Bunit.Core.dll

Represents a generalized Blazor renderer for testing purposes.

public interface ITestRenderer
Extension Methods

Properties

Dispatcher

Gets the Dispatcher associated with this ITestRenderer.

Dispatcher Dispatcher { get; }

Property Value

Dispatcher

UnhandledException

Gets a Task<TResult>, which completes when an unhandled exception is thrown during the rendering of a component, that is caught by the renderer.

Task<Exception> UnhandledException { get; }

Property Value

Task<Exception>

Methods

DispatchEventAsync(ulong, EventFieldInfo, EventArgs)

Notifies the renderer that an event has occurred.

Task DispatchEventAsync(ulong eventHandlerId, EventFieldInfo fieldInfo, EventArgs eventArgs)

Parameters

eventHandlerId ulong

The AttributeEventHandlerId value from the original event attribute.

fieldInfo EventFieldInfo

Information that the renderer can use to update the state of the existing render tree to match the UI.

eventArgs EventArgs

Arguments to be passed to the event handler.

Returns

Task

A Task which will complete once all asynchronous processing related to the event has completed.

DispatchEventAsync(ulong, EventFieldInfo, EventArgs, bool)

Notifies the renderer that an event has occurred.

Task DispatchEventAsync(ulong eventHandlerId, EventFieldInfo fieldInfo, EventArgs eventArgs, bool ignoreUnknownEventHandlers)

Parameters

eventHandlerId ulong

The AttributeEventHandlerId value from the original event attribute.

fieldInfo EventFieldInfo

Information that the renderer can use to update the state of the existing render tree to match the UI.

eventArgs EventArgs

Arguments to be passed to the event handler.

ignoreUnknownEventHandlers bool

Set to true to ignore the UnknownEventHandlerIdException.

Returns

Task

A Task which will complete once all asynchronous processing related to the event has completed.

DisposeComponents()

Disposes all components rendered by the ITestRenderer.

void DisposeComponents()

FindComponent<TComponent>(IRenderedFragmentBase)

Performs a depth-first search for the first TComponent child component of the parentComponent.

IRenderedComponentBase<TComponent> FindComponent<TComponent>(IRenderedFragmentBase parentComponent) where TComponent : IComponent

Parameters

parentComponent IRenderedFragmentBase

Parent component to search.

Returns

IRenderedComponentBase<TComponent>

Type Parameters

TComponent

Type of component to find.

FindComponents<TComponent>(IRenderedFragmentBase)

Performs a depth-first search for all TComponent child components of the parentComponent.

IReadOnlyList<IRenderedComponentBase<TComponent>> FindComponents<TComponent>(IRenderedFragmentBase parentComponent) where TComponent : IComponent

Parameters

parentComponent IRenderedFragmentBase

Parent component to search.

Returns

IReadOnlyList<IRenderedComponentBase<TComponent>>

Type Parameters

TComponent

Type of components to find.

RenderComponent<TComponent>(ComponentParameterCollection)

Renders a TComponent with the parameters passed to it.

IRenderedComponentBase<TComponent> RenderComponent<TComponent>(ComponentParameterCollection parameters) where TComponent : IComponent

Parameters

parameters ComponentParameterCollection

The parameters to pass to the component.

Returns

IRenderedComponentBase<TComponent>

A IRenderedComponentBase<TComponent> that provides access to the rendered component.

Type Parameters

TComponent

The type of component to render.

RenderFragment(RenderFragment)

Renders the renderFragment.

IRenderedFragmentBase RenderFragment(RenderFragment renderFragment)

Parameters

renderFragment RenderFragment

The RenderFragment to render.

Returns

IRenderedFragmentBase

A IRenderedFragmentBase that provides access to the rendered renderFragment.

Progress Telerik

Premium sponsor: Progress Telerik.

Packt

Editorial support provided by Packt.

.NET Foundation

Supported by the .NET Foundation.