Skip to content

Commit

Permalink
Update to xUnit v3 (#180)
Browse files Browse the repository at this point in the history
* Update to xUnit v3

* Give the build pipeline a punt

* Fix .NET 9 tests

---------

Co-authored-by: JT <Hawxy@users.noreply.github.com>
  • Loading branch information
Hawxy and Hawxy authored Dec 30, 2024
1 parent 300913a commit 2b80fdd
Show file tree
Hide file tree
Showing 21 changed files with 813 additions and 725 deletions.
4 changes: 2 additions & 2 deletions build/_build.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<TargetFramework>net9.0</TargetFramework>
<RootNamespace></RootNamespace>
<NoWarn>CS0649;CS0169;CA1050;CA1822;CA2211;IDE1006</NoWarn>
<NukeRootDirectory>..</NukeRootDirectory>
Expand All @@ -12,7 +12,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Nuke.Common" Version="9.0.1" />
<PackageReference Include="Nuke.Common" Version="9.0.3" />
</ItemGroup>

</Project>
4 changes: 2 additions & 2 deletions docs/guide/xunit.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,15 +40,15 @@ public class WebAppFixture : IAsyncLifetime
{
public IAlbaHost AlbaHost = null!;

public async Task InitializeAsync()
public async ValueTask InitializeAsync()
{
AlbaHost = await Alba.AlbaHost.For<WebApp.Program>(builder =>
{
// Configure all the things
});
}

public async Task DisposeAsync()
public async ValueTask DisposeAsync()
{
await AlbaHost.DisposeAsync();
}
Expand Down
2 changes: 1 addition & 1 deletion docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ layout: home

hero:
name: Alba
text: Easy Integration testing for ASP.NET Core
text: Easy Integration Testing for ASP.NET Core
actions:
- theme: brand
text: Get Started
Expand Down
2 changes: 1 addition & 1 deletion docs/scenarios/setup.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,5 +43,5 @@ public void sample_usage(AlbaHost system)

}
```
<sup><a href='https://github.com/JasperFx/alba/blob/master/src/Alba.Testing/before_and_after_actions.cs#L33-L66' title='Snippet source file'>snippet source</a> | <a href='#snippet-sample_before_and_after' title='Start of snippet'>anchor</a></sup>
<sup><a href='https://github.com/JasperFx/alba/blob/master/src/Alba.Testing/before_and_after_actions.cs#L32-L65' title='Snippet source file'>snippet source</a> | <a href='#snippet-sample_before_and_after' title='Start of snippet'>anchor</a></sup>
<!-- endSnippet -->
1,461 changes: 775 additions & 686 deletions package-lock.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"docs-build": "npm-run-all -s mdsnippets vitepress-build"
},
"dependencies": {
"vitepress": "1.3.4"
"vitepress": "1.5.0"
},
"devDependencies": {
"npm-run-all": "^4.1.5"
Expand Down
4 changes: 2 additions & 2 deletions src/Alba.Testing/Acceptance/specs_against_aspnet_core_app.cs
Original file line number Diff line number Diff line change
Expand Up @@ -382,12 +382,12 @@ public Task returns_successfully_when_passed_object_is_passed_to_Input()
});
}

public async Task InitializeAsync()
public async ValueTask InitializeAsync()
{
_system = await AlbaHost.For<Startup>();
}

public async Task DisposeAsync()
public async ValueTask DisposeAsync()
{
await _system.DisposeAsync();
}
Expand Down
9 changes: 5 additions & 4 deletions src/Alba.Testing/Alba.Testing.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<TargetFramework>net9.0</TargetFramework>
<IsPackable>false</IsPackable>
<OutputType>Exe</OutputType>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\Alba\Alba.csproj" />
Expand All @@ -15,10 +16,10 @@

<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.12.0" />
<PackageReference Include="NSubstitute" Version="5.1.0" />
<PackageReference Include="NSubstitute" Version="5.3.0" />
<PackageReference Include="Shouldly" Version="4.2.1" />
<PackageReference Include="xunit" Version="2.9.2" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.8.2">
<PackageReference Include="xunit.v3" Version="1.0.0" />
<PackageReference Include="xunit.runner.visualstudio" Version="3.0.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
using Oakton;
using Shouldly;
using Xunit;
using Xunit.Abstractions;

namespace Alba.Testing.MimimalApi;

Expand All @@ -19,7 +18,7 @@ public end_to_end_with_json_serialization(ITestOutputHelper output)
_output = output;
}

public async Task InitializeAsync()
public async ValueTask InitializeAsync()
{
OaktonEnvironment.AutoStartHost = true;
_host = await AlbaHost.For<MinimalApiWithOakton.Program>();
Expand All @@ -28,9 +27,9 @@ public async Task InitializeAsync()
_output.WriteLine(container.WhatDoIHave());
}

public Task DisposeAsync()
public async ValueTask DisposeAsync()
{
return _host.StopAsync();
await _host.StopAsync();
}

[Fact]
Expand Down
4 changes: 2 additions & 2 deletions src/Alba.Testing/Samples/ContractTestWithAlba.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,15 @@ public class WebAppFixture : IAsyncLifetime
{
public IAlbaHost AlbaHost = null!;

public async Task InitializeAsync()
public async ValueTask InitializeAsync()
{
AlbaHost = await Alba.AlbaHost.For<WebApp.Program>(builder =>
{
// Configure all the things
});
}

public async Task DisposeAsync()
public async ValueTask DisposeAsync()
{
await AlbaHost.DisposeAsync();
}
Expand Down
8 changes: 4 additions & 4 deletions src/Alba.Testing/Security/IdentityServerFixture.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,16 @@ public class IdentityServerCollection : ICollectionFixture<IdentityServerFixture
public class IdentityServerFixture : IAsyncLifetime
{
public TestServer IdentityServer { get; set; }
public Task InitializeAsync()
public ValueTask InitializeAsync()
{
IdentityServer = new WebApplicationFactory<IdentityServer.New.Program>().Server;
return Task.CompletedTask;
return ValueTask.CompletedTask;
}

public Task DisposeAsync()
public ValueTask DisposeAsync()
{
IdentityServer.Dispose();
return Task.CompletedTask;
return ValueTask.CompletedTask;
}

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public OpenConnectClientCredentialsTests(IdentityServerFixture fixture)
_fixture = fixture;
}

public async Task InitializeAsync()
public async ValueTask InitializeAsync()
{
#region sample_OpenConnectClientCredentials

Expand Down Expand Up @@ -51,7 +51,7 @@ public async Task InitializeAsync()
#endregion
}

public async Task DisposeAsync()
public async ValueTask DisposeAsync()
{
await theHost.DisposeAsync();
}
Expand Down
4 changes: 2 additions & 2 deletions src/Alba.Testing/Security/OpenConnectUserPasswordTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public OpenConnectUserPasswordTests(IdentityServerFixture fixture)
_fixture = fixture;
}

public async Task InitializeAsync()
public async ValueTask InitializeAsync()
{
#region sample_applying_OpenConnectUserPassword

Expand Down Expand Up @@ -51,7 +51,7 @@ public async Task InitializeAsync()
#endregion
}

public async Task DisposeAsync()
public async ValueTask DisposeAsync()
{
await theHost.DisposeAsync();
}
Expand Down
4 changes: 2 additions & 2 deletions src/Alba.Testing/Security/web_api_authentication_with_jwt.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public class web_api_authentication_with_jwt : IAsyncLifetime
{
private IAlbaHost theHost = null!;

public async Task InitializeAsync()
public async ValueTask InitializeAsync()
{
#region sample_setup_jwt_stub
// This is a new Alba extension that can "stub" out
Expand All @@ -31,7 +31,7 @@ public async Task InitializeAsync()
#endregion
}

public async Task DisposeAsync()
public async ValueTask DisposeAsync()
{
await theHost.DisposeAsync();
}
Expand Down
4 changes: 2 additions & 2 deletions src/Alba.Testing/Security/web_api_authentication_with_stub.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public class web_api_authentication_with_stub : IAsyncLifetime
{
private IAlbaHost theHost = null!;

public async Task InitializeAsync()
public async ValueTask InitializeAsync()
{
#region sample_bootstrapping_with_stub_extension
// This is a Alba extension that can "stub" out authentication
Expand All @@ -32,7 +32,7 @@ public async Task InitializeAsync()
#endregion
}

public async Task DisposeAsync()
public async ValueTask DisposeAsync()
{
await theHost.DisposeAsync();
}
Expand Down
1 change: 0 additions & 1 deletion src/Alba.Testing/before_and_after_actions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
using Microsoft.Extensions.Hosting;
using Shouldly;
using Xunit;
using Xunit.Abstractions;

namespace Alba.Testing
{
Expand Down
6 changes: 3 additions & 3 deletions src/MinimalApiWithOakton/MinimalApiWithOakton.csproj
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
<Project Sdk="Microsoft.NET.Sdk.Web">

<PropertyGroup>
<TargetFrameworks>net6.0;net8.0</TargetFrameworks>
<TargetFramework>net9.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Lamar.Microsoft.DependencyInjection" Version="13.0.4" />
<PackageReference Include="Oakton" Version="6.1.0" />
<PackageReference Include="Lamar.Microsoft.DependencyInjection" Version="14.0.1" />
<PackageReference Include="Oakton" Version="6.3.0" />
</ItemGroup>

</Project>
2 changes: 1 addition & 1 deletion src/NUnitSamples/NUnitSamples.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<TargetFramework>net9.0</TargetFramework>

<IsPackable>false</IsPackable>
</PropertyGroup>
Expand Down
2 changes: 1 addition & 1 deletion src/TUnitSamples/TUnitSamples.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<TargetFramework>net9.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
Expand Down
2 changes: 1 addition & 1 deletion src/WebApiNet6/WebApiNet6.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Oakton" Version="4.7.0" />
<PackageReference Include="Oakton" Version="6.3.0" />
</ItemGroup>

</Project>
2 changes: 1 addition & 1 deletion src/WebAppSecuredWithJwt/WebAppSecuredWithJwt.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="8.0.7" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="7.1.0" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="7.2.0" />
</ItemGroup>

</Project>

0 comments on commit 2b80fdd

Please sign in to comment.