Table of Contents

Class RenderedFragmentExtensions

Namespace
Bunit
Assembly
Bunit.Web.dll

Helper methods for querying IRenderedFragment.

public static class RenderedFragmentExtensions
Inheritance
RenderedFragmentExtensions
Inherited Members

Methods

Find(IRenderedFragment, string)

Returns the first element from the rendered fragment or component under test, using the provided cssSelector, in a depth-first pre-order traversal of the rendered nodes.

public static IElement Find(this IRenderedFragment renderedFragment, string cssSelector)

Parameters

renderedFragment IRenderedFragment

The rendered fragment to search.

cssSelector string

The group of selectors to use.

Returns

IElement

FindAll(IRenderedFragment, string, bool)

Returns a refreshable collection of AngleSharp.Dom.IElements from the rendered fragment or component under test, using the provided cssSelector, in a depth-first pre-order traversal of the rendered nodes.

public static IRefreshableElementCollection<IElement> FindAll(this IRenderedFragment renderedFragment, string cssSelector, bool enableAutoRefresh = false)

Parameters

renderedFragment IRenderedFragment

The rendered fragment to search.

cssSelector string

The group of selectors to use.

enableAutoRefresh bool

If true, the returned IRefreshableElementCollection<T> will automatically refresh its AngleSharp.Dom.IElements whenever the renderedFragment changes.

Returns

IRefreshableElementCollection<IElement>

An IRefreshableElementCollection<T>, that can be refreshed to execute the search again.

FindComponent<TComponent>(IRenderedFragment)

Finds the first component of type TComponent in the render tree of this IRenderedFragment.

public static IRenderedComponent<TComponent> FindComponent<TComponent>(this IRenderedFragment renderedFragment) where TComponent : IComponent

Parameters

renderedFragment IRenderedFragment

Returns

IRenderedComponent<TComponent>

The IRenderedComponent<TComponent>.

Type Parameters

TComponent

Type of component to find.

Exceptions

ComponentNotFoundException

Thrown if a component of type TComponent was not found in the render tree.

FindComponents<TComponent>(IRenderedFragment)

Finds all components of type TComponent in the render tree of this IRenderedFragment, in depth-first order.

public static IReadOnlyList<IRenderedComponent<TComponent>> FindComponents<TComponent>(this IRenderedFragment renderedFragment) where TComponent : IComponent

Parameters

renderedFragment IRenderedFragment

Returns

IReadOnlyList<IRenderedComponent<TComponent>>

The IRenderedComponent<TComponent>s.

Type Parameters

TComponent

Type of components to find.

HasComponent<TComponent>(IRenderedFragment)

Checks whether the render tree the renderedFragment is the root of contains a component of type TComponent.

public static bool HasComponent<TComponent>(this IRenderedFragment renderedFragment) where TComponent : IComponent

Parameters

renderedFragment IRenderedFragment

The render tree to search.

Returns

bool

True if the renderedFragment contains the TComponent; otherwise false.

Type Parameters

TComponent

The type of component to look for in the render tree.

.NET Foundation

Supported by the .NET Foundation.