Table of Contents

Class ApplicationFixtureExtensions

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

Extension methods for the IApplicationFixture<TEntryPoint> interface.

public static class ApplicationFixtureExtensions
Inheritance
ApplicationFixtureExtensions

Examples

The following example validates that an IApplicationFixture<TEntryPoint> has been fully initialized with host, configure callback, and configure-host callback by calling HasValidState<TEntryPoint> on the fixture. This is useful in assertion helpers to confirm the fixture was set up correctly before running the test scenario.

using Codebelt.Extensions.Xunit.Hosting;

namespace HostFixtureTests;

public class HostStateGuard
{
    public bool EnsureFixtureIsReady<TEntryPoint>(IApplicationFixture<TEntryPoint> fixture) where TEntryPoint : class
    {
        return fixture.HasValidState<TEntryPoint>();
    }
}

Methods

HasValidState<TEntryPoint>(IApplicationFixture<TEntryPoint>)

Determines whether the specified IApplicationFixture<TEntryPoint> has a valid state.

public static bool HasValidState<TEntryPoint>(this IApplicationFixture<TEntryPoint> hostFixture) where TEntryPoint : class

Parameters

hostFixture IApplicationFixture<TEntryPoint>

The IApplicationFixture<TEntryPoint> to check.

Returns

bool

true if the specified IApplicationFixture<TEntryPoint> has a valid state; otherwise, false.

Type Parameters

TEntryPoint

A type in the entry point assembly of the application.

Remarks

A valid state is defined as having non-null values for the following properties: Host, ConfigureCallback and ConfigureHostCallback.