-
-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ef8d045
commit c7fb5c9
Showing
6 changed files
with
103 additions
and
0 deletions.
There are no files selected for viewing
45 changes: 45 additions & 0 deletions
45
tests/TestAspNetCoreApiAot/TestAspNetCoreApiAot/Program.cs
This file contains 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,45 @@ | ||
using System.Text.Json.Serialization; | ||
|
||
namespace TestAspNetCoreApiAot | ||
{ | ||
public class Program | ||
{ | ||
public static void Main(string[] args) | ||
{ | ||
var builder = WebApplication.CreateSlimBuilder(args); | ||
|
||
builder.Services.ConfigureHttpJsonOptions(options => | ||
{ | ||
options.SerializerOptions.TypeInfoResolverChain.Insert(0, AppJsonSerializerContext.Default); | ||
}); | ||
builder.Services.AddMiniAuth(); | ||
|
||
var app = builder.Build(); | ||
|
||
var sampleTodos = new Todo[] { | ||
new(1, "Walk the dog"), | ||
new(2, "Do the dishes", DateOnly.FromDateTime(DateTime.Now)), | ||
new(3, "Do the laundry", DateOnly.FromDateTime(DateTime.Now.AddDays(1))), | ||
new(4, "Clean the bathroom"), | ||
new(5, "Clean the car", DateOnly.FromDateTime(DateTime.Now.AddDays(2))) | ||
}; | ||
|
||
var todosApi = app.MapGroup("/todos"); | ||
todosApi.MapGet("/", () => sampleTodos); | ||
todosApi.MapGet("/{id}", (int id) => | ||
sampleTodos.FirstOrDefault(a => a.Id == id) is { } todo | ||
? Results.Ok(todo) | ||
: Results.NotFound()); | ||
|
||
app.Run(); | ||
} | ||
} | ||
|
||
public record Todo(int Id, string? Title, DateOnly? DueBy = null, bool IsComplete = false); | ||
|
||
[JsonSerializable(typeof(Todo[]))] | ||
internal partial class AppJsonSerializerContext : JsonSerializerContext | ||
{ | ||
|
||
} | ||
} |
15 changes: 15 additions & 0 deletions
15
tests/TestAspNetCoreApiAot/TestAspNetCoreApiAot/Properties/launchSettings.json
This file contains 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,15 @@ | ||
{ | ||
"$schema": "http://json.schemastore.org/launchsettings.json", | ||
"profiles": { | ||
"http": { | ||
"commandName": "Project", | ||
"dotnetRunMessages": true, | ||
"launchBrowser": true, | ||
"launchUrl": "todos", | ||
"applicationUrl": "http://localhost:5170", | ||
"environmentVariables": { | ||
"ASPNETCORE_ENVIRONMENT": "Development" | ||
} | ||
} | ||
} | ||
} |
15 changes: 15 additions & 0 deletions
15
tests/TestAspNetCoreApiAot/TestAspNetCoreApiAot/TestAspNetCoreApiAot.csproj
This file contains 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,15 @@ | ||
<Project Sdk="Microsoft.NET.Sdk.Web"> | ||
|
||
<PropertyGroup> | ||
<TargetFramework>net8.0</TargetFramework> | ||
<Nullable>enable</Nullable> | ||
<ImplicitUsings>enable</ImplicitUsings> | ||
<InvariantGlobalization>true</InvariantGlobalization> | ||
<PublishAot>true</PublishAot> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="MiniAuth" Version="0.9.2" /> | ||
</ItemGroup> | ||
|
||
</Project> |
11 changes: 11 additions & 0 deletions
11
tests/TestAspNetCoreApiAot/TestAspNetCoreApiAot/TestAspNetCoreApiAot.http
This file contains 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,11 @@ | ||
@TestAspNetCoreApiAot_HostAddress = http://localhost:5170 | ||
|
||
GET {{TestAspNetCoreApiAot_HostAddress}}/todos/ | ||
Accept: application/json | ||
|
||
### | ||
|
||
GET {{TestAspNetCoreApiAot_HostAddress}}/todos/1 | ||
Accept: application/json | ||
|
||
### |
8 changes: 8 additions & 0 deletions
8
tests/TestAspNetCoreApiAot/TestAspNetCoreApiAot/appsettings.Development.json
This file contains 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,8 @@ | ||
{ | ||
"Logging": { | ||
"LogLevel": { | ||
"Default": "Information", | ||
"Microsoft.AspNetCore": "Warning" | ||
} | ||
} | ||
} |
9 changes: 9 additions & 0 deletions
9
tests/TestAspNetCoreApiAot/TestAspNetCoreApiAot/appsettings.json
This file contains 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,9 @@ | ||
{ | ||
"Logging": { | ||
"LogLevel": { | ||
"Default": "Information", | ||
"Microsoft.AspNetCore": "Warning" | ||
} | ||
}, | ||
"AllowedHosts": "*" | ||
} |