Table of Contents

Class HostTest<T>

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

Represents a base class from which all implementations of unit testing, that uses Microsoft Dependency Injection, should derive.

public abstract class HostTest<T> : HostTest, IAsyncLifetime, IHostTest, IConfigurationTest, IEnvironmentTest, ITest, IDisposable, IAsyncDisposable, IClassFixture<T> where T : class, IGenericHostFixture

Type Parameters

T

The type of the object that implements the IGenericHostFixture interface.

Inheritance
HostTest<T>
Implements
IAsyncLifetime
IClassFixture<T>
Derived
Inherited Members

Remarks

The class needed to be designed in this rather complex way, as this is the only way that xUnit supports a shared context. The need for shared context is theoretical at best, but it does opt-in for Scoped instances.

Constructors

HostTest(T, ITestOutputHelper, Type)

Initializes a new instance of the HostTest<T> class.

protected HostTest(T hostFixture, ITestOutputHelper output = null, Type callerType = null)

Parameters

hostFixture T

An implementation of the IGenericHostFixture interface.

output ITestOutputHelper

An implementation of the Xunit.Abstractions.ITestOutputHelper interface.

callerType Type

The Type of caller that ends up invoking this instance.

Exceptions

ArgumentNullException

hostFixture is null.

HostTest(Boolean, T, ITestOutputHelper, Type)

Initializes a new instance of the HostTest<T> class.

protected HostTest(bool skipHostFixtureInitialization, T hostFixture, ITestOutputHelper output = null, Type callerType = null)

Parameters

skipHostFixtureInitialization Boolean

A value indicating whether to skip the host fixture initialization.

hostFixture T

An implementation of the IGenericHostFixture interface.

output ITestOutputHelper

An implementation of the Xunit.Abstractions.ITestOutputHelper interface.

callerType Type

The Type of caller that ends up invoking this instance.

Exceptions

ArgumentNullException

hostFixture is null.

Methods

ConfigureHost(IHostBuilder)

Provides a way to override the IHostBuilder defaults set up by T.

protected virtual void ConfigureHost(IHostBuilder hb)

Parameters

hb IHostBuilder

The IHostBuilder that initializes an instance of IHost.

ConfigureServices(IServiceCollection)

Adds services to the container.

public abstract void ConfigureServices(IServiceCollection services)

Parameters

services IServiceCollection

The collection of service descriptors.

See Also

HostTest
IHostTest
IClassFixture<TFixture>