FastMoq
Search Results for

    Show / Hide Table of Contents

    Class ComponentState

    Wrapper around the renderer state used by FastMoq's Blazor helpers.

    Inheritance
    object
    ComponentState
    ComponentState<T>
    Inherited Members
    object.Equals(object)
    object.Equals(object, object)
    object.GetHashCode()
    object.GetType()
    object.MemberwiseClone()
    object.ReferenceEquals(object, object)
    object.ToString()
    Namespace: FastMoq.Web.Blazor.Models
    Assembly: FastMoq.Web.dll
    Syntax
    public class ComponentState
    Remarks

    FastMoq uses this wrapper instead of exposing raw renderer internals directly because bUnit 2 changed the shape of the renderer state it stores for rendered components. Consumers should prefer GetOrCreateRenderedComponent(Type) or GetOrCreateRenderedComponent<T>() over reflecting on renderer state objects themselves.

    Constructors

    ComponentState(object?, BunitRenderer, IRenderedComponent<IComponent>?)

    Initializes a new instance of the ComponentState class.

    Declaration
    public ComponentState(object? obj, BunitRenderer renderer, IRenderedComponent<IComponent>? rootComponent = null)
    Parameters
    Type Name Description
    object obj

    The raw renderer state object.

    BunitRenderer renderer

    The renderer.

    IRenderedComponent<IComponent> rootComponent

    The rendered root component used for nested component lookups when needed.

    Exceptions
    Type Condition
    ArgumentNullException

    renderer

    Properties

    Component

    Gets the component.

    Declaration
    public IComponent? Component { get; }
    Property Value
    Type Description
    IComponent

    The component.

    ComponentId

    Gets the component identifier.

    Declaration
    public int ComponentId { get; }
    Property Value
    Type Description
    int

    The component identifier.

    ComponentType

    Gets or sets the type of the component.

    Declaration
    protected Type ComponentType { get; set; }
    Property Value
    Type Description
    Type

    The type of the component.

    CurrentRenderTree

    Gets the current render tree.

    Declaration
    public RenderTreeBuilder? CurrentRenderTree { get; }
    Property Value
    Type Description
    RenderTreeBuilder

    The current render tree.

    IsComponentBase

    Gets a value indicating whether this instance is component base.

    Declaration
    public bool IsComponentBase { get; }
    Property Value
    Type Description
    bool

    true if this instance is component base; otherwise, false.

    ParentComponentState

    Gets the state of the parent component.

    Declaration
    public ComponentState? ParentComponentState { get; }
    Property Value
    Type Description
    ComponentState

    The state of the parent component.

    Methods

    GetOrCreateRenderedComponent(Type)

    Gets the or create rendered component.

    Declaration
    public IRenderedComponent<IComponent>? GetOrCreateRenderedComponent(Type type)
    Parameters
    Type Name Description
    Type type

    The type.

    Returns
    Type Description
    IRenderedComponent<IComponent>

    System ofNullable<IRenderedComponent<IComponent>> of the or create rendered component.

    Remarks

    This method understands both direct rendered-component state values and the fallback lookup path required by bUnit 2's renderer state dictionary.

    GetOrCreateRenderedComponent<T>()

    Gets the or create rendered component.

    Declaration
    public virtual IRenderedComponent<T>? GetOrCreateRenderedComponent<T>() where T : ComponentBase
    Returns
    Type Description
    IRenderedComponent<T>

    System ofNullable<IRenderedComponent<T>> of the or create rendered component.

    Type Parameters
    Name Description
    T

    The component type.

    Examples
    var state = GetAllComponents<FetchData>().First().Value as ComponentState<FetchData>;
    var rendered = state?.GetOrCreateRenderedComponent<FetchData>();

    Extension Methods

    ObjectExtensions.RaiseIfNull<T>(T?, string?, string?, int?, string?)
    TestClassExtensions.GetFieldValue<TObject>(TObject, string, TObject?)
    TestClassExtensions.GetField<TObject>(TObject, string)
    TestClassExtensions.GetMemberName<T, TValue>(T, Expression<Func<T, TValue>>)
    TestClassExtensions.GetMember<T, TValue>(T, Expression<Func<T, TValue>>)
    TestClassExtensions.GetMethodValue<TObject>(TObject, string, object?, params object[])
    TestClassExtensions.GetMethod<TObject>(TObject, string)
    TestClassExtensions.GetPropertyValue<TObject>(TObject, string, object?)
    TestClassExtensions.GetProperty<TObject>(TObject, string)
    TestClassExtensions.SetFieldValue<TObject>(TObject, string, object?)
    TestClassExtensions.SetPropertyValue<TObject>(TObject, string, object?)
    MockerHttpMoqExtensions.SetupHttpMessage(object, Func<HttpResponseMessage>, Expression?, Expression?)
    MockerHttpMoqExtensions.SetupMessageAsync<TMock, TReturn>(object, Expression<Func<TMock, Task<TReturn>>>, Func<TReturn>)
    MockerHttpMoqExtensions.SetupMessageProtectedAsync<TMock, TReturn>(object, string, Func<TReturn>, params object?[]?)
    MockerHttpMoqExtensions.SetupMessageProtected<TMock, TReturn>(object, string, Func<TReturn>, params object?[]?)
    MockerHttpMoqExtensions.SetupMessage<TMock, TReturn>(object, Expression<Func<TMock, TReturn>>, Func<TReturn>)
    TestClassExtensions.GetFieldInfo<TType>(object, string)
    TestClassExtensions.GetFieldValue<T>(object?, FieldInfo)
    TestClassExtensions.GetFieldValue<T, TType>(object, string)
    In this article
    Back to top
    Generated 2026-04-29 03:53 UTC