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
TThe type of the object that implements the IGenericHostFixture interface.
- Inheritance
-
HostTest<T>
- Implements
-
IAsyncLifetimeIClassFixture<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(bool, 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
skipHostFixtureInitializationboolA value indicating whether to skip the host fixture initialization.
hostFixtureTAn implementation of the IGenericHostFixture interface.
outputITestOutputHelperAn implementation of the Xunit.ITestOutputHelper interface.
callerTypeTypeThe Type of caller that ends up invoking this instance.
Exceptions
- ArgumentNullException
hostFixtureis null.
HostTest(T, ITestOutputHelper, Type)
Initializes a new instance of the HostTest<T> class.
protected HostTest(T hostFixture, ITestOutputHelper output = null, Type callerType = null)
Parameters
hostFixtureTAn implementation of the IGenericHostFixture interface.
outputITestOutputHelperAn implementation of the Xunit.ITestOutputHelper interface.
callerTypeTypeThe Type of caller that ends up invoking this instance.
Exceptions
- ArgumentNullException
hostFixtureis null.
Methods
ConfigureHost(IHostBuilder)
Provides a way to override the IHostBuilder defaults set up by T.
protected virtual void ConfigureHost(IHostBuilder hb)
Parameters
hbIHostBuilderThe IHostBuilder that initializes an instance of IHost.
ConfigureServices(IServiceCollection)
Adds services to the container.
public abstract void ConfigureServices(IServiceCollection services)
Parameters
servicesIServiceCollectionThe collection of service descriptors.