-
Notifications
You must be signed in to change notification settings - Fork 1
V11.2.0/startup fix #68
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
dbe5314
✨ add managed application fixtures for entrypoint-owned startup
aicia-bot cebe2b8
✅ add tests for managed application fixtures
aicia-bot 141c4c6
📝 update api documentation for managed fixtures
aicia-bot a41de10
📦 update package release notes for managed startup
aicia-bot bc051de
💬 release notes for 11.2.0
aicia-bot 6937f7a
♻️ consolidate entrypoint hosting logic into managed fixtures
aicia-bot ea8585e
✅ verify managed fixtures start the application entrypoint
aicia-bot dce3991
📝 update fixture usage examples in api documentation
aicia-bot a3937b1
🎨 align exception handler formatting
aicia-bot 712065c
🐛 fix bootstrapper async startup and cancellation handling
gimlichael File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
50 changes: 50 additions & 0 deletions
50
...odebelt.Extensions.Xunit.Hosting.AspNetCore.ManagedWebApplicationFixture%601.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,50 @@ | ||
| --- | ||
| uid: Codebelt.Extensions.Xunit.Hosting.AspNetCore.ManagedWebApplicationFixture`1 | ||
| example: | ||
| - *content | ||
| --- | ||
|
|
||
| Use `ManagedWebApplicationFixture<TEntryPoint>` when an xUnit class fixture should exercise an ASP.NET Core application's real entry point and let that entry point start the in-memory server. Derive the test from `WebApplicationTest<TEntryPoint,T>` and pass the fixture to its base constructor so the base class initializes the fixture through `ConfigureHost` before the test reads `Server`. This is an opt-in path for the current minor release. Fixture setup remains lazy; consuming the test host starts the deferred host, after which the test can create a client from the exposed `TestServer` and verify the application's endpoint behavior. The legacy blocking path is retained for compatibility until it can be removed or changed in the next major release. | ||
|
|
||
| ```csharp | ||
| using System.Threading.Tasks; | ||
| using Codebelt.Extensions.Xunit.Hosting.AspNetCore; | ||
| using Microsoft.AspNetCore.Builder; | ||
| using Microsoft.Extensions.DependencyInjection; | ||
| using Xunit; | ||
|
|
||
| namespace CatalogApi.Tests; | ||
|
|
||
| public sealed class CatalogApiTest : WebApplicationTest<CatalogProgram, ManagedWebApplicationFixture<CatalogProgram>> | ||
| { | ||
| public CatalogApiTest(ManagedWebApplicationFixture<CatalogProgram> fixture, ITestOutputHelper output) | ||
| : base(fixture, output) | ||
| { | ||
| } | ||
|
|
||
| [Fact] | ||
| public async Task HealthEndpoint_ReturnsApplicationState() | ||
| { | ||
| using var client = Server.CreateClient(); | ||
|
|
||
| var body = await client.GetStringAsync("/health").ConfigureAwait(false); | ||
|
|
||
| Assert.Equal("ready", body); | ||
| } | ||
| } | ||
|
|
||
| public sealed record CatalogStatus(string Value); | ||
|
|
||
| public sealed class CatalogProgram | ||
| { | ||
| public static void Main(string[] args) | ||
| { | ||
| var builder = WebApplication.CreateBuilder(args); | ||
| builder.Services.AddSingleton(new CatalogStatus("ready")); | ||
|
|
||
| var app = builder.Build(); | ||
| app.MapGet("/health", (CatalogStatus status) => status.Value); | ||
| app.Run(); | ||
| } | ||
| } | ||
| ``` |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
46 changes: 46 additions & 0 deletions
46
...fx/api/types/Codebelt.Extensions.Xunit.Hosting.ManagedApplicationFixture%601.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,46 @@ | ||
| --- | ||
| uid: Codebelt.Extensions.Xunit.Hosting.ManagedApplicationFixture`1 | ||
| example: | ||
| - *content | ||
| --- | ||
|
|
||
| Use `ManagedApplicationFixture<TEntryPoint>` when an xUnit class fixture should exercise the application's real entry point and let that entry point start the host. Derive the test from `ApplicationTest<TEntryPoint,T>` and pass the fixture to its base constructor so the base class initializes the fixture through `ConfigureHost` before the test reads `Host`. This is an opt-in path for the current minor release. Fixture setup remains lazy; accessing the test host starts the deferred host and surfaces startup failures at the point the test consumes it. The legacy blocking path is retained for compatibility until it can be removed or changed in the next major release. | ||
|
|
||
| ```csharp | ||
| using Codebelt.Extensions.Xunit.Hosting; | ||
| using Microsoft.Extensions.DependencyInjection; | ||
| using Microsoft.Extensions.Hosting; | ||
| using Xunit; | ||
|
|
||
| namespace InventoryWorker.Tests; | ||
|
|
||
| public sealed class InventoryWorkerTest : ApplicationTest<WorkerProgram, ManagedApplicationFixture<WorkerProgram>> | ||
| { | ||
| public InventoryWorkerTest(ManagedApplicationFixture<WorkerProgram> fixture, ITestOutputHelper output) | ||
| : base(fixture, output) | ||
| { | ||
| } | ||
|
|
||
| [Fact] | ||
| public void Host_ContainsApplicationService() | ||
| { | ||
| var identity = Host.Services.GetRequiredService<WorkerIdentity>(); | ||
|
|
||
| Assert.Equal("Inventory worker", identity.Name); | ||
| } | ||
| } | ||
|
|
||
| public sealed record WorkerIdentity(string Name); | ||
|
|
||
| public sealed class WorkerProgram | ||
| { | ||
| public static void Main(string[] args) | ||
| { | ||
| var builder = Host.CreateApplicationBuilder(args); | ||
| builder.Services.AddSingleton(new WorkerIdentity("Inventory worker")); | ||
|
|
||
| using var host = builder.Build(); | ||
| host.Run(); | ||
| } | ||
| } | ||
| ``` | ||
13 changes: 13 additions & 0 deletions
13
.nuget/Codebelt.Extensions.Xunit.Hosting.AspNetCore/PackageReleaseNotes.txt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 13 additions & 0 deletions
13
.nuget/Codebelt.Extensions.Xunit.Hosting/PackageReleaseNotes.txt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.