Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions .github/workflows/build-and-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,9 @@ jobs:
uses: actions/setup-dotnet@v5
with:
dotnet-version: |
6.x
7.x
8.x
9.x
10.x
- name: Restore
run: dotnet restore
- name: Build
Expand All @@ -51,7 +50,10 @@ jobs:
- name: Setup .NET Core
uses: actions/setup-dotnet@v5
with:
dotnet-version: 9.x
dotnet-version: |
8.x
9.x
10.x
- name: Restore tools
run: dotnet tool restore
- name: Build solution
Expand Down
6 changes: 2 additions & 4 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,9 @@ jobs:
uses: actions/setup-dotnet@v5
with:
dotnet-version: |
6.x
7.x
8.x
9.x
10.x
- name: Restore
run: dotnet restore
- name: Build
Expand All @@ -55,10 +54,9 @@ jobs:
uses: actions/setup-dotnet@v5
with:
dotnet-version: |
6.x
7.x
8.x
9.x
10.x
- name: Create Release NuGet package
run: |
arrTag=(${GITHUB_REF//\// })
Expand Down
6 changes: 5 additions & 1 deletion tests/Giraffe.Tests/Giraffe.Tests.fsproj
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>net8.0;net9.0</TargetFrameworks>
<TargetFrameworks>net8.0;net9.0;net10.0</TargetFrameworks>
<AssemblyName>Giraffe.Tests</AssemblyName>
</PropertyGroup>

Expand Down Expand Up @@ -46,6 +46,10 @@
<PackageReference Include="Microsoft.AspNetCore.TestHost" Version="9.0.*" />
</ItemGroup>

<ItemGroup Condition=" '$(TargetFramework)' == 'net10.0'">
<PackageReference Include="Microsoft.AspNetCore.TestHost" Version="10.0.*" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="18.0.1" />
<PackageReference Include="xunit" Version="2.9.*" />
Expand Down
21 changes: 21 additions & 0 deletions tests/Giraffe.Tests/Helpers.fs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ open Microsoft.AspNetCore.Hosting
open Microsoft.AspNetCore.TestHost
open Microsoft.AspNetCore.Builder
open Microsoft.Extensions.DependencyInjection
open Microsoft.Extensions.Hosting
open Xunit
open NSubstitute
open Giraffe
Expand Down Expand Up @@ -94,10 +95,22 @@ let createHost
(configureServices: IServiceCollection -> unit)
(args: 'Tuple)
=
#if NET10_0_OR_GREATER
HostBuilder()
.ConfigureWebHost(fun webHostBuilder ->
webHostBuilder
.UseTestServer()
.UseContentRoot(Path.GetFullPath("TestFiles"))
.Configure(Action<IApplicationBuilder>(configureApp args))
.ConfigureServices(Action<IServiceCollection> configureServices)
|> ignore
)
#else
(WebHostBuilder())
.UseContentRoot(Path.GetFullPath("TestFiles"))
.Configure(Action<IApplicationBuilder>(configureApp args))
.ConfigureServices(Action<IServiceCollection> configureServices)
#endif

let mockJson (ctx: HttpContext) =

Expand Down Expand Up @@ -131,7 +144,15 @@ let createRequest (method: HttpMethod) (path: string) =

let makeRequest configureApp configureServices args (request: HttpRequestMessage) =
task {
#if NET10_0_OR_GREATER
// https://github.com/aspnet/Announcements/issues/526
use host = createHost configureApp configureServices args |> _.Build()

let! _ = host.StartAsync()
use server = host.GetTestServer()
#else
use server = new TestServer(createHost configureApp configureServices args)
#endif
use client = server.CreateClient()
let! response = request |> client.SendAsync
return response
Expand Down