Table of Contents

Namespace Codebelt.Extensions.Xunit.Hosting.AspNetCore

The Codebelt.Extensions.Xunit.Hosting.AspNetCore namespace contains types that provides a uniform way of doing unit testing that depends on ASP.NET Core and used in conjunction with Microsoft Dependency Injection. The namespace relates to the Microsoft.AspNetCore.TestHost namespace.

Availability: .NET 9 and .NET 8

Complements: Microsoft.AspNetCore.TestHost namespace 🔗

Extension Methods

Type Ext Methods
HttpClient ⬇️ ToHttpResponseMessageAsync
IServiceCollection ⬇️ AddFakeHttpContextAccessor

Classes

BlockingManagedWebHostFixture

Extends the default implementation of the IWebHostFixture interface to be synchronous e.g., blocking where exceptions can be captured.

HostBuilderApplicationExtensions

Provides extension methods for IHostApplicationBuilder.

HttpClientExtensions

Provides extension methods for the HttpClient class.

ManagedWebHostFixture

Provides a default implementation of the IWebHostFixture interface.

ManagedWebMinimalHostFixture

Provides a default implementation of the IWebMinimalHostFixture interface.

MinimalWebHostTest<T>

Represents a base class from which all implementations of unit testing, that uses Microsoft Dependency Injection and depends on ASP.NET Core (minimal style), should derive.

MinimalWebHostTestFactory

Provides a set of static methods for ASP.NET Core (including, but not limited to MVC, Razor and related) unit testing (minimal style).

SelfManagedWebHostFixture

Represents a self-managed implementation of the ManagedWebHostFixture class.

SelfManagedWebMinimalHostFixture

Represents a self-managed implementation of the ManagedMinimalHostFixture class.

ServiceCollectionExtensions

Extension methods for the IServiceCollection interface.

WebHostFixtureExtensions

Extension methods for the IWebHostFixture interface.

WebHostTest<T>

Represents a base class from which all implementations of unit testing, that uses Microsoft Dependency Injection and depends on ASP.NET Core, should derive.

WebHostTestFactory

Provides a set of static methods for ASP.NET Core (including, but not limited to MVC, Razor and related) unit testing.

WebMinimalHostFixtureExtensions

Extension methods for the IWebMinimalHostFixture interface.

Interfaces

IPipelineTest

Represents the members needed for ASP.NET Core pipeline testing.

IWebHostFixture

Provides a way to use Microsoft Dependency Injection in unit tests tailored for ASP.NET Core.

IWebHostTest

Represents the members needed for ASP.NET Core (including but not limited to MVC, Razor and related) testing.

IWebMinimalHostFixture

Provides a way to use Microsoft Dependency Injection in unit tests (minimal style).