Table of Contents

Create Method

Definition

Namespace
Codebelt.Extensions.Xunit.Hosting
Assemblies
Codebelt.Extensions.Xunit.Hosting.dll
Source
src/Codebelt.Extensions.Xunit.Hosting/ApplicationHostFactory.cs

Create<TEntryPoint>(Action<IHostBuilder>)

Creates, configures and builds an IHost from the assembly containing TEntryPoint.

public static IHost Create<TEntryPoint>(Action<IHostBuilder> configureHost) where TEntryPoint : class

Parameters

configureHost Action<IHostBuilder>

The delegate that provides a way to override the IHostBuilder before the application is built.

Returns

IHost

A built IHost instance.

Type Parameters

TEntryPoint

A type in the entry point assembly of the application.

Remarks

For compatibility, applications that expose CreateHostBuilder(string[]) are built through that factory. Applications that do not expose the legacy factory use the deferred entry-point path. Managed application fixtures use the deferred entry-point path so the application owns startup.

Exceptions

InvalidOperationException

The entry point assembly does not expose a supported application host.

Create<TEntryPoint>(Action<IHostBuilder>, bool)

Creates, configures and builds an IHost from the assembly containing TEntryPoint.

public static IHost Create<TEntryPoint>(Action<IHostBuilder> configureHost, bool stopApplication) where TEntryPoint : class

Parameters

configureHost Action<IHostBuilder>

The delegate that provides a way to override the IHostBuilder before the application is built.

stopApplication bool

A value indicating whether the entry point should be stopped after the host is built.

Returns

IHost

A built IHost instance.

Type Parameters

TEntryPoint

A type in the entry point assembly of the application.

Remarks

For compatibility, applications that expose CreateHostBuilder(string[]) are built through that factory and the stopApplication value is ignored for that path. Managed application fixtures use the deferred entry-point path so the application owns startup.

Exceptions

InvalidOperationException

The entry point assembly does not expose a supported application host.