Namespace Codebelt.Extensions.Xunit.Hosting
The Codebelt.Extensions.Xunit.Hosting
namespace contains types that provides a uniform way of doing unit testing that is used in conjunction with Microsoft Dependency Injection. The namespace relates to the Xunit.Abstractions
namespace.
Availability: .NET 9, .NET 8 and .NET Standard 2.0
Complements: xUnit: Shared Context between Tests 🔗
Extension Methods
Type | Ext | Methods |
---|---|---|
ILogger{T} | ⬇️ | GetTestStore |
IServiceCollection | ⬇️ | AddXunitTestOutputHelperAccessor |
IServiceProvider | ⬇️ | GetRequiredScopedService |
Classes
- GenericHostTestFactory
Provides a set of static methods for Microsoft.Extensions.Hosting.IHost unit testing.
- HostFixture
Provides a default implementation of the IHostFixture interface.
- HostTest<T>
Represents a base class from which all implementations of unit testing, that uses Microsoft Dependency Injection, should derive.
- LoggerExtensions
Extension methods for the Microsoft.Extensions.Logging.ILogger<TCategoryName> interface.
- ServiceCollectionExtensions
Extension methods for the Microsoft.Extensions.DependencyInjection.IServiceCollection interface.
- ServiceProviderExtensions
Provides extension methods for the System.IServiceProvider interface.
- XunitTestLoggerEntry
Represents a captured log-entry for testing purposes. This record encapsulates the Microsoft.Extensions.Logging.LogLevel, Microsoft.Extensions.Logging.EventId and message.
Interfaces
- IConfigurationTest
Represents the members needed for DI testing with support for Configuration.
- IGenericHostTest
Represents the members needed for bare-bone DI testing with support for Microsoft.Extensions.Hosting.IHost.
- IHostFixture
Provides a way to use Microsoft Dependency Injection in unit tests.
- IHostingEnvironmentTest
Represents the members needed for DI testing with support for HostingEnvironment.
- IHostTest
Represents the members needed for DI host testing.
- IServiceTest
Represents the members needed for DI services testing.