WebHostFixtureExtensions Class
Definition
- Namespace
- Codebelt.Extensions.Xunit.Hosting.AspNetCore
- Assemblies
- 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;
using Xunit;
namespace WebFixtureTests;
public class WebHostStateGuard
{
public bool EnsureFixtureIsReady(IWebHostFixture fixture)
{
return fixture.HasValidState();
}
}
public sealed class RunExample
{
[Fact]
public void ExercisesExample()
{
using var fixture = new ManagedWebHostFixture();
Assert.False(new WebHostStateGuard().EnsureFixtureIsReady(fixture));
using var app = WebHostTestFactory.Create(hostFixture: fixture);
Assert.True(new WebHostStateGuard().EnsureFixtureIsReady(fixture));
}
}
Methods
| Name | Description |
|---|---|
| HasValidState(IWebHostFixture) | Determines whether the specified IWebHostFixture has a valid state. |