Class WebHostFixtureExtensions
- Namespace
- Codebelt.Extensions.Xunit.Hosting.AspNetCore
- Assembly
- Codebelt.Extensions.Xunit.Hosting.AspNetCore.dll
Extension methods for the IWebHostFixture interface.
public static class WebHostFixtureExtensions
- Inheritance
-
WebHostFixtureExtensions
Examples
The following example validates that an IWebHostFixture has a valid initialized state by calling HasValidState. The method checks that the underlying generic host fixture is valid and that the application configure callback is set.
using Codebelt.Extensions.Xunit.Hosting.AspNetCore;
namespace WebFixtureTests;
public class WebHostStateGuard
{
public bool EnsureFixtureIsReady(IWebHostFixture fixture)
{
return fixture.HasValidState();
}
}
Methods
HasValidState(IWebHostFixture)
Determines whether the specified IWebHostFixture has a valid state.
public static bool HasValidState(this IWebHostFixture hostFixture)
Parameters
hostFixtureIWebHostFixtureThe IWebHostFixture to check.
Returns
- bool
trueif the specified IWebHostFixture has a valid state; otherwise,false.
Remarks
A valid state is defined as having non-null values for the following properties: ConfigureApplicationCallback, ConfigureServicesCallback and ConfigureHostCallback.