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

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

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.