Class TestContextBase
- Namespace
- Bunit
- Assembly
- Bunit.Core.dll
A test context is a factory that makes it possible to create components under tests.
public abstract class TestContextBase : IDisposable
- Inheritance
-
TestContextBase
- Implements
- Derived
- Inherited Members
- Extension Methods
Constructors
TestContextBase()
Initializes a new instance of the TestContextBase class.
protected TestContextBase()
Properties
ComponentFactories
Gets the ComponentFactoryCollection. Factories added to it will be used to create components during testing, starting with the last added factory. If no factories in the collection can create a requested component, then the default Blazor factory is used.
public ComponentFactoryCollection ComponentFactories { get; }
Property Value
DefaultWaitTimeout
Gets or sets the default wait timeout used by "WaitFor" operations, i.e. WaitForAssertion(IRenderedFragmentBase, Action, TimeSpan?).
public static TimeSpan DefaultWaitTimeout { get; set; }
Property Value
Remarks
The default is 1 second.
RenderTree
Gets the RootRenderTree that all components rendered with the
RenderComponent<TComponent>()
methods, are rendered inside.
public RootRenderTree RenderTree { get; }
Property Value
Remarks
Use this to add default layout- or root-components which a component under test should be rendered under.
Renderer
Gets the renderer used by the test context.
public ITestRenderer Renderer { get; }
Property Value
Services
Gets the service collection and service provider that is used when a component is rendered by the test context.
public TestServiceProvider Services { get; }
Property Value
Methods
CreateTestRenderer()
Creates the renderer.
protected abstract ITestRenderer CreateTestRenderer()
Returns
Dispose()
public void Dispose()
Dispose(bool)
Disposes of the test context resources, in particular it disposes the Services service provider. Any async services registered with the service provider will disposed first, but their disposal will not be awaited..
protected virtual void Dispose(bool disposing)
Parameters
Remarks
The disposing parameter should be false when called from a finalizer, and true when called from the Dispose() method. In other words, it is true when deterministically called and false when non-deterministically called.
DisposeComponents()
Disposes all components rendered via this TestContextBase.
public void DisposeComponents()