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
renderedFragmentIRenderedFragmentThe rendered fragment to search.
cssSelectorstringThe 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
renderedFragmentIRenderedFragmentThe rendered fragment to search.
cssSelectorstringThe group of selectors to use.
enableAutoRefreshboolIf true, the returned IRefreshableElementCollection<T> will automatically refresh its AngleSharp.Dom.IElements whenever the
renderedFragmentchanges.
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
renderedFragmentIRenderedFragment
Returns
- IRenderedComponent<TComponent>
Type Parameters
TComponentType of component to find.
Exceptions
- ComponentNotFoundException
Thrown if a component of type
TComponentwas 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
renderedFragmentIRenderedFragment
Returns
- IReadOnlyList<IRenderedComponent<TComponent>>
Type Parameters
TComponentType 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
renderedFragmentIRenderedFragmentThe render tree to search.
Returns
- bool
True if the
renderedFragmentcontains theTComponent; otherwise false.
Type Parameters
TComponentThe type of component to look for in the render tree.