Skip to content

Commit

Permalink
Update to xUnit v3
Browse files Browse the repository at this point in the history
  • Loading branch information
Hawxy committed Dec 30, 2024
1 parent 300913a commit 00f7431
Show file tree
Hide file tree
Showing 15 changed files with 803 additions and 715 deletions.
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
7 changes: 4 additions & 3 deletions src/Alba.Testing/Alba.Testing.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
<PropertyGroup>
<TargetFramework>net8.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

0 comments on commit 00f7431

Please sign in to comment.