Table of Contents

Class RootRenderTree

Namespace
Bunit.Rendering
Assembly
Bunit.Core.dll

Represents a root render tree, wherein components under tests will be rendered. Components added to the render tree must have either a ChildContent or Body parameter.

public sealed class RootRenderTree : IReadOnlyCollection<RootRenderTreeRegistration>, IEnumerable<RootRenderTreeRegistration>, IEnumerable
Inheritance
RootRenderTree
Implements
Inherited Members
Extension Methods

Constructors

RootRenderTree()

public RootRenderTree()

Properties

Count

public int Count { get; }

Property Value

int

Methods

Add<TComponent>(Action<ComponentParameterCollectionBuilder<TComponent>>?)

Adds a component to the render tree. This method can be called multiple times, with each invocation adding a component to the render tree. The TComponent must have a ChildContent or Body parameter.

public void Add<TComponent>(Action<ComponentParameterCollectionBuilder<TComponent>>? parameterBuilder = null) where TComponent : IComponent

Parameters

parameterBuilder Action<ComponentParameterCollectionBuilder<TComponent>>

An optional parameter builder, used to pass parameters to TComponent.

Type Parameters

TComponent

The type of the component to add to the render tree.

GetCountOf<TComponent>()

Gets the number of registered components of type TComponent in the render tree.

public int GetCountOf<TComponent>() where TComponent : IComponent

Returns

int

Number of components of type TComponent in render tree.

Type Parameters

TComponent

Component type to count.

GetEnumerator()

public IEnumerator<RootRenderTreeRegistration> GetEnumerator()

Returns

IEnumerator<RootRenderTreeRegistration>

TryAdd<TComponent>(Action<ComponentParameterCollectionBuilder<TComponent>>?)

Try to add a component to the render tree if it has not already been added. This method can be called multiple times, with each invocation adding a component to the render tree. The TComponent must have a ChildContent or Body parameter.

public bool TryAdd<TComponent>(Action<ComponentParameterCollectionBuilder<TComponent>>? parameterBuilder = null) where TComponent : IComponent

Parameters

parameterBuilder Action<ComponentParameterCollectionBuilder<TComponent>>

An optional parameter builder, used to pass parameters to TComponent.

Returns

bool

True if component was added, false if it was previously added and not added again.

Type Parameters

TComponent

The type of the component to add to the render tree.

Remarks

This method will only add the component to the render tree if it has not already been added. Use Add<TComponent>(Action<ComponentParameterCollectionBuilder<TComponent>>?) to add the same component multiple times.

Wrap(RenderFragment)

Creates a new RenderFragment that wraps target inside the components registered in this RootRenderTree.

public RenderFragment Wrap(RenderFragment target)

Parameters

target RenderFragment

RenderFragment to render inside the render tree.

Returns

RenderFragment

A RenderFragment that renders the target inside this RootRenderTree render tree.

.NET Foundation

Supported by the .NET Foundation.