Table of Contents

Class HostFixture

Namespace
Codebelt.Extensions.Xunit.Hosting
Assembly
Codebelt.Extensions.Xunit.Hosting.dll

Represents the base class from which all implementations of xUnit fixture concept should derive.

public abstract class HostFixture : IHostFixture, IConfigurationTest, IEnvironmentTest, IDisposable, IAsyncDisposable, IAsyncLifetime
Inheritance
HostFixture
Implements
IAsyncLifetime
Derived

Constructors

HostFixture()

Initializes a new instance of the HostFixture class.

protected HostFixture()

Properties

AsyncHostRunnerCallback

Gets or sets the delegate responsible for running the IHost.

protected Func<IHost, CancellationToken, Task> AsyncHostRunnerCallback { get; set; }

Property Value

Func<IHost, CancellationToken, Task>

The delegate responsible for running the IHost.

Exceptions

ArgumentNullException

value cannot be null.

Configuration

Gets the IConfiguration initialized by this instance.

public IConfiguration Configuration { get; protected set; }

Property Value

IConfiguration

The IConfiguration initialized by this instance.

ConfigureCallback

Gets or sets the delegate that initializes the test class.

public Action<IConfiguration, IHostEnvironment> ConfigureCallback { get; set; }

Property Value

Action<IConfiguration, IHostEnvironment>

The delegate that initializes the test class.

Remarks

Mimics the Startup convention.

Disposed

Gets a value indicating whether this HostFixture object is disposed.

public bool Disposed { get; }

Property Value

Boolean

true if this HostFixture object is disposed; otherwise, false.

Environment

Gets the IHostEnvironment initialized by this instance.

public IHostEnvironment Environment { get; protected set; }

Property Value

IHostEnvironment

The IHostEnvironment initialized by this instance.

Host

Gets or sets the IHost initialized by this instance.

public IHost Host { get; protected set; }

Property Value

IHost

The IHost initialized by this instance.

Methods

Dispose()

Releases all resources used by the HostFixture object.

public void Dispose()

Dispose(Boolean)

Releases the unmanaged resources used by the HostFixture object and optionally releases the managed resources.

protected void Dispose(bool disposing)

Parameters

disposing Boolean

true to release both managed and unmanaged resources; false to release only unmanaged resources.

DisposeAsync()

Asynchronously releases the resources used by the HostFixture.

public async ValueTask DisposeAsync()

Returns

ValueTask

A ValueTask that represents the asynchronous dispose operation.

Remarks

HasTypes(Type, Type[])

Determines whether the specified type contains one or more of the specified target types.

protected static bool HasTypes(Type type, params Type[] types)

Parameters

type Type

The Type to validate.

types Type[]

The target types to be matched against.

Returns

Boolean

true if the type contains one or more of the specified target types; otherwise, false.

InitializeAsync()

Called immediately after the class has been created, before it is used.

public virtual Task InitializeAsync()

Returns

Task

A Task that represents the asynchronous operation.

OnDisposeManagedResources()

Called when this object is being disposed by either Dispose() or Dispose(Boolean) having disposing set to true and Disposed is false.

protected virtual void OnDisposeManagedResources()

OnDisposeManagedResourcesAsync()

Called when this object is being disposed by DisposeAsync().

protected virtual async ValueTask OnDisposeManagedResourcesAsync()

Returns

ValueTask

OnDisposeUnmanagedResources()

Called when this object is being disposed by either Dispose() or Dispose(Boolean) and Disposed is false.

protected virtual void OnDisposeUnmanagedResources()

Explicit Interface Implementations

IAsyncLifetime.DisposeAsync()

Task IAsyncLifetime.DisposeAsync()

Returns

Task

See Also