Skip to content

Commit 6c5fb36

Browse files
committed
use dual mode testing
1 parent ef92b0a commit 6c5fb36

11 files changed

Lines changed: 57 additions & 35 deletions

File tree

FastEndpoints.TemplatePack.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
<PropertyGroup>
44

5-
<Version>1.10.2</Version>
5+
<Version>1.11.0-beta.1</Version>
66

77
<PackageType>Template</PackageType>
88
<PackageId>FastEndpoints.TemplatePack</PackageId>

changelog.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1-
- upgrade FastEndpoints to latest `v8.0.1`
1+
- use dual mode testing for aot project
2+
- upgrade FastEndpoints to latest

templates/aot/.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -350,3 +350,5 @@ MigrationBackup/
350350
.ionide/
351351

352352
.idea/.idea.Ctma/.idea/workspace.xml
353+
354+
dotnet-tools.json
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
F8CBB731230F0CFEBBF1D8D68AED70BE0370931E02FC3002C05A132F22E440B4
1+
54E47863031D3155CCC5026F19E52A93229661D49D199F0E3A6F1CD7CCBE15F8

templates/aot/Source/Generated/FastEndpoints/SerializerContexts.g.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// <auto-generated />
22
// Generated by FastEndpoints.Generator.Cli
3-
// Generated at: 2026-02-16 17:36:24
3+
// Generated at: 2026-03-03 11:47:07
44

55
#pragma warning disable
66
#nullable enable

templates/aot/Source/MyApp.csproj

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,11 @@
1818
</PropertyGroup>
1919

2020
<ItemGroup>
21-
<PackageReference Include="FastEndpoints" Version="8.0.1"/>
22-
<PackageReference Include="FastEndpoints.Generator" Version="8.0.1" PrivateAssets="all" IncludeAssets="runtime; build; native; contentfiles; analyzers; buildtransitive"/>
23-
<PackageReference Include="FastEndpoints.Security" Version="8.0.1"/>
24-
<PackageReference Include="FastEndpoints.Swagger" Version="8.0.1"/>
25-
<PackageReference Include="Scalar.AspNetCore" Version="2.12.30"/>
21+
<PackageReference Include="FastEndpoints" Version="8.1.0-beta.9"/>
22+
<PackageReference Include="FastEndpoints.Generator" Version="8.1.0-beta.9" PrivateAssets="all" IncludeAssets="runtime; build; native; contentfiles; analyzers; buildtransitive"/>
23+
<PackageReference Include="FastEndpoints.Security" Version="8.1.0-beta.9"/>
24+
<PackageReference Include="FastEndpoints.Swagger" Version="8.1.0-beta.9"/>
25+
<PackageReference Include="Scalar.AspNetCore" Version="2.12.52"/>
2626
</ItemGroup>
2727

2828
<ItemGroup>

templates/aot/Source/Program.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@
1919

2020
await app.ExportSwaggerDocsAndExitAsync("v1");
2121

22+
app.MapGet("/healthy", () => Results.Ok()).ExcludeFromDescription();
23+
2224
app.UseOpenApi(c => c.Path = "/openapi/{documentName}.json");
2325
app.MapScalarApiReference(o => o.AddDocument("v1"));
2426

templates/aot/Source/dotnet-tools.json

Lines changed: 0 additions & 13 deletions
This file was deleted.

templates/aot/Tests/App.cs

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,50 @@
1-
using Microsoft.AspNetCore.Hosting;
1+
using System.Text.Json;
2+
using Microsoft.AspNetCore.Hosting;
23

34
namespace Tests.SayHello;
45

56
public class App : AppFixture<Program>
67
{
78
protected override ValueTask SetupAsync()
89
{
9-
// place one-time setup for the fixture here
10+
// place one-time setup for the fixture here.
11+
1012
return ValueTask.CompletedTask;
1113
}
1214

1315
protected override void ConfigureApp(IWebHostBuilder a)
1416
{
15-
// do host builder configuration here
17+
// do host builder configuration here.
18+
// only called when running under WAF mode.
1619
}
1720

1821
protected override void ConfigureServices(IServiceCollection s)
1922
{
20-
// do test service registration here
23+
// do test service registration here.
24+
// only called when running under WAF mode.
25+
}
26+
27+
protected override ValueTask ConfigureAotTargetAsync(AotTargetOptions o)
28+
{
29+
// settings for building and running a native aot black-box instance.
30+
// all settings are optional. customization only needed if auto management fails.
31+
32+
o.BuildTimeoutMinutes = 1;
33+
o.HealthEndpointPath = "/healthy";
34+
o.ReadyTimeoutSeconds = 5;
35+
o.EnvironmentVariables["ASPNETCORE_ENVIRONMENT"] = "Testing";
36+
37+
// make routeless test helpers use the same serializer settings as the app
38+
39+
new Config().Serializer.Options.PropertyNamingPolicy = JsonNamingPolicy.CamelCase;
40+
41+
return ValueTask.CompletedTask;
2142
}
2243

2344
protected override ValueTask TearDownAsync()
2445
{
2546
// do cleanups here
47+
2648
return ValueTask.CompletedTask;
2749
}
2850
}

templates/aot/Tests/SayHello/Tests.cs

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,16 @@ public async Task Invalid_User_Input()
2222
[Fact, Priority(2)]
2323
public async Task Valid_User_Input()
2424
{
25-
var (rsp, res) = await App.Client.POSTAsync<Endpoint, Request, Response>(
26-
new()
27-
{
28-
FirstName = "Mike",
29-
LastName = "Kelso"
30-
});
25+
var (rsp, res, err) = await App.Client.POSTAsync<Endpoint, Request, Response>(
26+
new()
27+
{
28+
FirstName = "Mike",
29+
LastName = "Kelso"
30+
});
31+
32+
if (!rsp.IsSuccessStatusCode)
33+
Assert.Fail(err);
3134

32-
rsp.StatusCode.ShouldBe(HttpStatusCode.OK);
3335
res.Message.ShouldBe("Hello Mike Kelso...");
3436
}
3537
}

0 commit comments

Comments
 (0)