Class WebApplicationFixtureExtensions
- Namespace
- Codebelt.Extensions.Xunit.Hosting.AspNetCore
- Assembly
- Codebelt.Extensions.Xunit.Hosting.AspNetCore.dll
Extension methods for the IWebApplicationFixture<TEntryPoint> interface.
public static class WebApplicationFixtureExtensions
- Inheritance
-
WebApplicationFixtureExtensions
Examples
The following example validates that an IWebApplicationFixture<TEntryPoint> has a valid initialized state by calling HasValidState<TEntryPoint>. The method checks that the host, configure callback, and configure-web-host callback are all non-null.
using Codebelt.Extensions.Xunit.Hosting.AspNetCore;
namespace WebFixtureTests;
public class WebAppStateGuard
{
public bool EnsureFixtureIsReady<TEntryPoint>(IWebApplicationFixture<TEntryPoint> fixture) where TEntryPoint : class
{
return fixture.HasValidState<TEntryPoint>();
}
}
Methods
HasValidState<TEntryPoint>(IWebApplicationFixture<TEntryPoint>)
Determines whether the specified IWebApplicationFixture<TEntryPoint> has a valid state.
public static bool HasValidState<TEntryPoint>(this IWebApplicationFixture<TEntryPoint> hostFixture) where TEntryPoint : class
Parameters
hostFixtureIWebApplicationFixture<TEntryPoint>The IWebApplicationFixture<TEntryPoint> to check.
Returns
- bool
trueif the specified IWebApplicationFixture<TEntryPoint> has a valid state; otherwise,false.
Type Parameters
TEntryPointA 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 ConfigureWebHostCallback.