Table of Contents

Class RenderedComponentExtensions

Namespace
Bunit
Assembly
bunit.dll

Helper methods for querying IRenderedComponent<TComponent>.

public static class RenderedComponentExtensions
Inheritance
RenderedComponentExtensions
Inherited Members

Methods

FindAll<TComponent>(IRenderedComponent<TComponent>, string)

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 IReadOnlyList<IElement> FindAll<TComponent>(this IRenderedComponent<TComponent> renderedComponent, string cssSelector) where TComponent : IComponent

Parameters

renderedComponent IRenderedComponent<TComponent>

The rendered fragment to search.

cssSelector string

The group of selectors to use.

Returns

IReadOnlyList<IElement>

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

Type Parameters

TComponent

FindAll<TComponent, TElement>(IRenderedComponent<TComponent>, string)

Returns a collection of elements of type TElement from the rendered fragment or component under test, using the provided cssSelector, in a depth-first pre-order traversal of the rendered nodes. Only elements matching the type TElement are returned.

public static IReadOnlyList<TElement> FindAll<TComponent, TElement>(this IRenderedComponent<TComponent> renderedComponent, string cssSelector) where TComponent : IComponent where TElement : class, IElement

Parameters

renderedComponent IRenderedComponent<TComponent>

The rendered fragment to search.

cssSelector string

The group of selectors to use.

Returns

IReadOnlyList<TElement>

An IReadOnlyList<T> containing only elements matching the specified type.

Type Parameters

TComponent

The type of the component under test.

TElement

The type of elements to find (e.g., IHtmlInputElement).

FindComponent<TChildComponent>(IRenderedComponent<IComponent>)

Finds the first component of type TChildComponent in the render tree of this IRenderedComponent<TComponent>.

public static IRenderedComponent<TChildComponent> FindComponent<TChildComponent>(this IRenderedComponent<IComponent> renderedComponent) where TChildComponent : IComponent

Parameters

renderedComponent IRenderedComponent<IComponent>

Returns

IRenderedComponent<TChildComponent>

The RenderedComponent<TComponent>.

Type Parameters

TChildComponent

Type of component to find.

Exceptions

ComponentNotFoundException

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

FindComponents<TChildComponent>(IRenderedComponent<IComponent>)

Finds all components of type TChildComponent in the render tree of this IRenderedComponent<TComponent>, in depth-first order.

public static IReadOnlyList<IRenderedComponent<TChildComponent>> FindComponents<TChildComponent>(this IRenderedComponent<IComponent> renderedComponent) where TChildComponent : IComponent

Parameters

renderedComponent IRenderedComponent<IComponent>

Returns

IReadOnlyList<IRenderedComponent<TChildComponent>>

The RenderedComponent<TComponent>s.

Type Parameters

TChildComponent

Type of components to find.

Find<TComponent>(IRenderedComponent<TComponent>, 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<TComponent>(this IRenderedComponent<TComponent> renderedComponent, string cssSelector) where TComponent : IComponent

Parameters

renderedComponent IRenderedComponent<TComponent>

The rendered fragment to search.

cssSelector string

The group of selectors to use.

Returns

IElement

Type Parameters

TComponent

Find<TComponent, TElement>(IRenderedComponent<TComponent>, string)

Returns the first element of type TElement 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 TElement Find<TComponent, TElement>(this IRenderedComponent<TComponent> renderedComponent, string cssSelector) where TComponent : IComponent where TElement : class, IElement

Parameters

renderedComponent IRenderedComponent<TComponent>

The rendered fragment to search.

cssSelector string

The group of selectors to use.

Returns

TElement

Type Parameters

TComponent

The type of the component under test.

TElement

The type of element to find (e.g., IHtmlInputElement).

Exceptions

ElementNotFoundException

Thrown if no element matches the cssSelector.

HasComponent<TChildComponent>(IRenderedComponent<IComponent>)

Checks whether the render tree the renderedComponent is the root of contains a component of type TChildComponent.

public static bool HasComponent<TChildComponent>(this IRenderedComponent<IComponent> renderedComponent) where TChildComponent : IComponent

Parameters

renderedComponent IRenderedComponent<IComponent>

The render tree to search.

Returns

bool

True if the renderedComponent contains the TChildComponent; otherwise false.

Type Parameters

TChildComponent

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

.NET Foundation

Supported by the .NET Foundation.