bUnit bUnit
Search Results for

    Show / Hide Table of Contents

    Class TestContext

    A test context is a factory that makes it possible to create components under tests.

    Inheritance
    System.Object
    TestContextBase
    TestContext
    Implements
    System.IDisposable
    Inherited Members
    TestContextBase.Renderer
    TestContextBase.Services
    TestContextBase.RenderTree
    TestContextBase.Dispose()
    TestContextBase.Dispose(Boolean)
    System.Object.Equals(System.Object)
    System.Object.Equals(System.Object, System.Object)
    System.Object.GetHashCode()
    System.Object.GetType()
    System.Object.MemberwiseClone()
    System.Object.ReferenceEquals(System.Object, System.Object)
    System.Object.ToString()
    Namespace: Bunit
    Assembly: Bunit.Web.dll
    Syntax
    public class TestContext : TestContextBase, IDisposable

    Constructors

    | Improve this Doc View Source

    TestContext()

    Initializes a new instance of the TestContext class.

    Declaration
    public TestContext()

    Properties

    | Improve this Doc View Source

    JSInterop

    Gets bUnits JSInterop, that allows setting up handlers for Microsoft.JSInterop.IJSRuntime.InvokeAsync``1(System.String,System.Object[]) invocations that components under tests will issue during testing. It also makes it possible to verify that the invocations has happened as expected.

    Declaration
    public BunitJSInterop JSInterop { get; }
    Property Value
    Type Description
    BunitJSInterop

    Methods

    | Improve this Doc View Source

    BuildRenderTree(RenderTreeBuilder)

    Dummy method required to allow Blazor's compiler to generate C# from .razor files.

    Declaration
    protected virtual void BuildRenderTree(RenderTreeBuilder builder)
    Parameters
    Type Name Description
    Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder builder
    | Improve this Doc View Source

    Render(RenderFragment)

    Renders the renderFragment and returns it as a IRenderedFragment.

    Declaration
    public virtual IRenderedFragment Render(RenderFragment renderFragment)
    Parameters
    Type Name Description
    Microsoft.AspNetCore.Components.RenderFragment renderFragment

    The render fragment to render.

    Returns
    Type Description
    IRenderedFragment

    The IRenderedFragment.

    | Improve this Doc View Source

    Render<TComponent>(RenderFragment)

    Renders the renderFragment and returns the first TComponent in the resulting render tree.

    Declaration
    public virtual IRenderedComponent<TComponent> Render<TComponent>(RenderFragment renderFragment)
    
        where TComponent : IComponent
    Parameters
    Type Name Description
    Microsoft.AspNetCore.Components.RenderFragment renderFragment

    The render fragment to render.

    Returns
    Type Description
    IRenderedComponent<TComponent>

    The IRenderedComponent<TComponent>.

    Type Parameters
    Name Description
    TComponent

    The type of component to find in the render tree.

    Remarks

    Calling this method is equivalent to calling Render(renderFragment).FindComponent<TComponent>().

    | Improve this Doc View Source

    RenderComponent<TComponent>(ComponentParameter[])

    Instantiates and performs a first render of a component of type TComponent.

    Declaration
    public virtual IRenderedComponent<TComponent> RenderComponent<TComponent>(params ComponentParameter[] parameters)
    
        where TComponent : IComponent
    Parameters
    Type Name Description
    ComponentParameter[] parameters

    Parameters to pass to the component when it is rendered.

    Returns
    Type Description
    IRenderedComponent<TComponent>

    The rendered TComponent.

    Type Parameters
    Name Description
    TComponent

    Type of the component to render.

    | Improve this Doc View Source

    RenderComponent<TComponent>(Action<ComponentParameterCollectionBuilder<TComponent>>)

    Instantiates and performs a first render of a component of type TComponent.

    Declaration
    public virtual IRenderedComponent<TComponent> RenderComponent<TComponent>(Action<ComponentParameterCollectionBuilder<TComponent>> parameterBuilder)
    
        where TComponent : IComponent
    Parameters
    Type Name Description
    System.Action<ComponentParameterCollectionBuilder<TComponent>> parameterBuilder

    The ComponentParameterBuilder action to add type safe parameters to pass to the component when it is rendered.

    Returns
    Type Description
    IRenderedComponent<TComponent>

    The rendered TComponent.

    Type Parameters
    Name Description
    TComponent

    Type of the component to render.

    Implements

    System.IDisposable

    Extension Methods

    JSRuntimeAssertExtensions.ShouldBeElementReferenceTo(Object, IElement)
    FakeAuthorizationExtensions.AddTestAuthorization(TestContextBase)

    Editorial support provided by Packt.

    • Improve this Doc
    • View Source
    Back to top Documentation updated on 4/14/2021 5:33:15 PM +00:00 in commit bf41b6407b.