Table of Contents

Class BlockingManagedWebHostFixture

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

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

public sealed class BlockingManagedWebHostFixture : ManagedWebHostFixture, IAsyncLifetime, IWebHostFixture, IGenericHostFixture, IHostFixture, IConfigurationTest, IEnvironmentTest, IDisposable, IAsyncDisposable, IPipelineTest
Inheritance
BlockingManagedWebHostFixture
Implements
IAsyncLifetime
Inherited Members
Extension Methods

Examples

The following example uses BlockingManagedWebHostFixture as a fixture for xUnit tests that need a synchronously started web host. The fixture manages the full web host lifecycle and blocks until the host is started before returning control to the test.

using Codebelt.Extensions.Xunit.Hosting.AspNetCore;
using Microsoft.Extensions.DependencyInjection;
using Xunit;

namespace WebFixtureTests;

public class WebHostIntegrationTest : IClassFixture<BlockingManagedWebHostFixture>
{
    private readonly BlockingManagedWebHostFixture _fixture;

    public WebHostIntegrationTest(BlockingManagedWebHostFixture fixture)
    {
        _fixture = fixture;
    }

    [Fact]
    public void HostShouldBeStarted()
    {
        Assert.True(_fixture.HasValidState());
    }
}

Constructors

BlockingManagedWebHostFixture()

Initializes a new instance of the BlockingManagedWebHostFixture class.

public BlockingManagedWebHostFixture()

See Also