Skip to content

Commit ed0c34e

Browse files
Update xUnit to latest v3 and resolve build issues (#5)
* Initial plan * Update xUnit to v3 and fix ValueTask return types Co-authored-by: JohnCampionJr <[email protected]> * Fix all cancellation token warnings for xUnit v3 Co-authored-by: JohnCampionJr <[email protected]> * update to stable xunit * fix warning * update workflow --------- Co-authored-by: copilot-swe-agent[bot] <[email protected]> Co-authored-by: JohnCampionJr <[email protected]> Co-authored-by: John Campion Jr <[email protected]>
1 parent 997c88e commit ed0c34e

29 files changed

+172
-175
lines changed

.github/workflows/dotnet-test.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ on:
55
branches: [main]
66
pull_request:
77
branches: [main]
8+
workflow_dispatch:
89

910
jobs:
1011
build:

Net9MultiTenant/Pages/NoTenant.cshtml.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ namespace Net9MultiTenant.Pages
1111
public class NoTenantModel() : PageModel
1212
{
1313
[ExcludeFromMultiTenantResolution]
14-
public async Task OnGet()
14+
public void OnGet()
1515
{
1616

1717
}

tests/MongoFramework.AspNetCore.Identity.Tests/MongoEntityFramework.AspNetCore.Identity.Tests.csproj

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,11 @@
1919
<ItemGroup>
2020
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="18.0.0" />
2121
<PackageReference Include="AwesomeAssertions" Version="9.2.1" />
22-
<PackageReference Include="xunit" Version="2.9.3" />
22+
<PackageReference Include="xunit.v3" Version="3.1.0" />
2323
<PackageReference Include="xunit.runner.visualstudio" Version="3.1.5">
2424
<PrivateAssets>all</PrivateAssets>
2525
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
2626
</PackageReference>
27-
<PackageReference Include="coverlet.collector" Version="6.0.4">
28-
<PrivateAssets>all</PrivateAssets>
29-
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
30-
</PackageReference>
3127
</ItemGroup>
3228

3329
<ItemGroup>

tests/MongoFramework.AspNetCore.Identity.Tests/MongoIdentityContextsTests.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ public class MongoIdentityContextsTests : TestBase, IAsyncLifetime
2222

2323
public MongoIdentityContextsTests() : base("MongoIdentityContexts") { }
2424

25-
public async Task InitializeAsync()
25+
public async ValueTask InitializeAsync()
2626
{
2727
var context = new MongoIdentityDbContext(GetConnection());
2828
var store = new MongoUserStore<MongoIdentityUser>(context);
@@ -40,7 +40,7 @@ public async Task InitializeAsync()
4040

4141
}
4242

43-
public Task DisposeAsync() => Task.CompletedTask;
43+
public ValueTask DisposeAsync() => ValueTask.CompletedTask;
4444

4545
[Fact]
4646
public void ContextWithRolesLoadsRoles()

tests/MongoFramework.AspNetCore.Identity.Tests/MongoRoleStoreTests.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ public class MongoRoleStoreTests : TestBase, IAsyncLifetime
1212

1313
public MongoRoleStoreTests() : base("MongoRoleStore") { }
1414

15-
public async Task InitializeAsync()
15+
public async ValueTask InitializeAsync()
1616
{
1717
var context = new MongoTestContext(GetConnection());
1818
var store = new MongoUserStore<MongoTestUser>(context);
@@ -30,7 +30,7 @@ public async Task InitializeAsync()
3030

3131
}
3232

33-
public Task DisposeAsync() => Task.CompletedTask;
33+
public ValueTask DisposeAsync() => ValueTask.CompletedTask;
3434

3535
[Fact]
3636
public void ConstructorUsesMongo()
@@ -71,7 +71,7 @@ public async Task GetNormalizedRoleReturnsCorrect()
7171
var store = new MongoRoleStore<MongoIdentityRole<int>, DbContext, int>(context);
7272

7373
var role = new MongoIdentityRole<int> { Name = "testrole", NormalizedName = "TESTROLE" };
74-
var name = await store.GetNormalizedRoleNameAsync(role);
74+
var name = await store.GetNormalizedRoleNameAsync(role, TestContext.Current.CancellationToken);
7575

7676
name.Should().Be("TESTROLE");
7777
}

tests/MongoFramework.AspNetCore.Identity.Tests/MongoUserOnlyStoreTests/AddClaims.cs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,29 +14,29 @@ public class AddClaims : TestBase, IAsyncLifetime
1414

1515
public AddClaims() : base("MongoUserOnlyStore-AddClaims") { }
1616

17-
public async Task InitializeAsync()
17+
public async ValueTask InitializeAsync()
1818
{
1919
var context = new MongoTestContext(GetConnection());
2020
var store = new MongoUserOnlyStore<MongoTestUser>(context);
2121

2222
await store.CreateAsync(MongoTestUser.First);
2323
}
2424

25-
public Task DisposeAsync() => Task.CompletedTask;
25+
public ValueTask DisposeAsync() => ValueTask.CompletedTask;
2626

2727
[Fact]
2828
public async Task UpdatesUser()
2929
{
3030
var context = new MongoTestContext(GetConnection());
3131
var store = new MongoUserOnlyStore<MongoTestUser>(context);
32-
var user = await store.FindByIdAsync(TestIds.UserId1);
32+
var user = await store.FindByIdAsync(TestIds.UserId1, TestContext.Current.CancellationToken);
3333

3434
await store.AddClaimsAsync(user,
3535
new[]
3636
{
3737
new Claim("type","value"),
3838
new Claim("type2", "value2")
39-
});
39+
}, TestContext.Current.CancellationToken);
4040

4141
user.Claims.Count.Should().Be(2);
4242
user.Claims[0].ClaimType.Should().Be("type");
@@ -47,20 +47,20 @@ public async Task SavesData()
4747
{
4848
var context = new MongoTestContext(GetConnection());
4949
var store = new MongoUserOnlyStore<MongoTestUser>(context);
50-
var user = await store.FindByIdAsync(TestIds.UserId1);
50+
var user = await store.FindByIdAsync(TestIds.UserId1, TestContext.Current.CancellationToken);
5151

5252
await store.AddClaimsAsync(user,
5353
new[]
5454
{
5555
new Claim("type","value"),
5656
new Claim("type2", "value2")
57-
});
57+
}, TestContext.Current.CancellationToken);
5858

59-
await store.UpdateAsync(user);
59+
await store.UpdateAsync(user, TestContext.Current.CancellationToken);
6060

6161
context = new MongoTestContext(GetConnection());
6262
store = new MongoUserOnlyStore<MongoTestUser>(context);
63-
user = await store.FindByIdAsync(TestIds.UserId1);
63+
user = await store.FindByIdAsync(TestIds.UserId1, TestContext.Current.CancellationToken);
6464

6565
user.Claims.Count.Should().Be(2);
6666
user.Claims[0].ClaimType.Should().Be("type");

tests/MongoFramework.AspNetCore.Identity.Tests/MongoUserOnlyStoreTests/AddLogin.cs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ public class AddLogin : TestBase, IAsyncLifetime
1414

1515
public AddLogin() : base("MongoUserOnlyStore-AddLogin") { }
1616

17-
public async Task InitializeAsync()
17+
public async ValueTask InitializeAsync()
1818
{
1919
var context = new MongoTestContext(GetConnection());
2020
var store = new MongoUserOnlyStore<MongoTestUser>(context);
@@ -24,16 +24,16 @@ public async Task InitializeAsync()
2424
await store.CreateAsync(MongoTestUser.Third);
2525
}
2626

27-
public Task DisposeAsync() => Task.CompletedTask;
27+
public ValueTask DisposeAsync() => ValueTask.CompletedTask;
2828

2929
[Fact]
3030
public async Task UpdatesUser()
3131
{
3232
var context = new MongoTestContext(GetConnection());
3333
var store = new MongoUserOnlyStore<MongoTestUser>(context);
34-
var user = await store.FindByIdAsync(TestIds.UserId1);
34+
var user = await store.FindByIdAsync(TestIds.UserId1, TestContext.Current.CancellationToken);
3535

36-
await store.AddLoginAsync(user, new UserLoginInfo("provider1", "provider-key", "Login Provider"));
36+
await store.AddLoginAsync(user, new UserLoginInfo("provider1", "provider-key", "Login Provider"), TestContext.Current.CancellationToken);
3737

3838
user.Logins.Count.Should().Be(1);
3939
user.Logins[0].LoginProvider.Should().Be("provider1");
@@ -44,14 +44,14 @@ public async Task SavesData()
4444
{
4545
var context = new MongoTestContext(GetConnection());
4646
var store = new MongoUserOnlyStore<MongoTestUser>(context);
47-
var user = await store.FindByIdAsync(TestIds.UserId1);
47+
var user = await store.FindByIdAsync(TestIds.UserId1, TestContext.Current.CancellationToken);
4848

49-
await store.AddLoginAsync(user, new UserLoginInfo("provider1", "provider-key", "Login Provider"));
50-
await store.UpdateAsync(user);
49+
await store.AddLoginAsync(user, new UserLoginInfo("provider1", "provider-key", "Login Provider"), TestContext.Current.CancellationToken);
50+
await store.UpdateAsync(user, TestContext.Current.CancellationToken);
5151

5252
context = new MongoTestContext(GetConnection());
5353
store = new MongoUserOnlyStore<MongoTestUser>(context);
54-
user = await store.FindByIdAsync(TestIds.UserId1);
54+
user = await store.FindByIdAsync(TestIds.UserId1, TestContext.Current.CancellationToken);
5555

5656
user.Logins.Count.Should().Be(1);
5757
user.Logins[0].LoginProvider.Should().Be("provider1");

tests/MongoFramework.AspNetCore.Identity.Tests/MongoUserOnlyStoreTests/CreateUser.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ public async Task ReturnsSuccessWithStringId()
2020
var context = new MongoTestContext(GetConnection());
2121
var store = new MongoUserOnlyStore<MongoTestUser>(context);
2222

23-
var result = await store.CreateAsync(MongoTestUser.First);
23+
var result = await store.CreateAsync(MongoTestUser.First, TestContext.Current.CancellationToken);
2424

2525
result.Should().Be(IdentityResult.Success);
2626
}
@@ -31,7 +31,7 @@ public async Task CreatesDataWithStringId()
3131
var context = new MongoTestContext(GetConnection());
3232
var store = new MongoUserOnlyStore<MongoTestUser>(context);
3333

34-
await store.CreateAsync(MongoTestUser.First);
34+
await store.CreateAsync(MongoTestUser.First, TestContext.Current.CancellationToken);
3535

3636
context.TestUsers.Any().Should().BeTrue();
3737
context.TestUsers.Count().Should().Be(1);
@@ -46,7 +46,7 @@ public async Task DoesNotCreatesDataWithAutoSaveOff()
4646

4747
store.AutoSaveChanges = false;
4848

49-
await store.CreateAsync(MongoTestUser.First);
49+
await store.CreateAsync(MongoTestUser.First, TestContext.Current.CancellationToken);
5050

5151
context.TestUsers.Any().Should().BeFalse();
5252
context.TestUsers.Count().Should().Be(0);
@@ -59,7 +59,7 @@ public async Task ReturnsSuccessWithIntId()
5959
var context = new MongoTestContext(GetConnection());
6060
var store = new MongoUserOnlyStore<MongoTestUserInt, DbContext, int>(context);
6161

62-
var result = await store.CreateAsync(MongoTestUserInt.First);
62+
var result = await store.CreateAsync(MongoTestUserInt.First, TestContext.Current.CancellationToken);
6363

6464
result.Should().Be(IdentityResult.Success);
6565
}
@@ -70,7 +70,7 @@ public async Task CreatesDataWithIntId()
7070
var context = new MongoTestContext(GetConnection());
7171
var store = new MongoUserOnlyStore<MongoTestUserInt, DbContext, int>(context);
7272

73-
await store.CreateAsync(MongoTestUserInt.First);
73+
await store.CreateAsync(MongoTestUserInt.First, TestContext.Current.CancellationToken);
7474

7575
context.TestUsersInt.Any().Should().BeTrue();
7676
context.TestUsersInt.Count().Should().Be(1);

tests/MongoFramework.AspNetCore.Identity.Tests/MongoUserOnlyStoreTests/DeleteUser.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,15 @@ public async Task DeletesDataWithValidUser()
1919
{
2020
var context = new MongoTestContext(GetConnection());
2121
var store = new MongoUserOnlyStore<MongoTestUser>(context);
22-
await store.CreateAsync(MongoTestUser.First);
22+
await store.CreateAsync(MongoTestUser.First, TestContext.Current.CancellationToken);
2323

2424
context.TestUsers.Any().Should().BeTrue();
2525

2626
context = new MongoTestContext(GetConnection());
2727
store = new MongoUserOnlyStore<MongoTestUser>(context);
28-
var user = await context.TestUsers.FirstOrDefaultAsync();
28+
var user = await context.TestUsers.FirstOrDefaultAsync(TestContext.Current.CancellationToken);
2929

30-
await store.DeleteAsync(user);
30+
await store.DeleteAsync(user, TestContext.Current.CancellationToken);
3131

3232
context.TestUsers.Any().Should().BeFalse();
3333
}
@@ -37,15 +37,15 @@ public async Task ReturnsSuccessWithValidUser()
3737
{
3838
var context = new MongoTestContext(GetConnection());
3939
var store = new MongoUserOnlyStore<MongoTestUser>(context);
40-
await store.CreateAsync(MongoTestUser.First);
40+
await store.CreateAsync(MongoTestUser.First, TestContext.Current.CancellationToken);
4141

4242
context.TestUsers.Any().Should().BeTrue();
4343

4444
context = new MongoTestContext(GetConnection());
4545
store = new MongoUserOnlyStore<MongoTestUser>(context);
46-
var user = await context.TestUsers.FirstOrDefaultAsync();
46+
var user = await context.TestUsers.FirstOrDefaultAsync(TestContext.Current.CancellationToken);
4747

48-
var result = await store.DeleteAsync(user);
48+
var result = await store.DeleteAsync(user, TestContext.Current.CancellationToken);
4949

5050
result.Should().Be(IdentityResult.Success);
5151
}

tests/MongoFramework.AspNetCore.Identity.Tests/MongoUserOnlyStoreTests/FindByEmail.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ public class FindByEmail : TestBase, IAsyncLifetime
1313

1414
public FindByEmail() : base("MongoUserOnlyStore-FindByEmail") { }
1515

16-
public async Task InitializeAsync()
16+
public async ValueTask InitializeAsync()
1717
{
1818
var context = new MongoTestContext(GetConnection());
1919
var store = new MongoUserOnlyStore<MongoTestUser>(context);
@@ -23,15 +23,15 @@ public async Task InitializeAsync()
2323
await store.CreateAsync(MongoTestUser.Third);
2424
}
2525

26-
public Task DisposeAsync() => Task.CompletedTask;
26+
public ValueTask DisposeAsync() => ValueTask.CompletedTask;
2727

2828
[Fact]
2929
public async Task FindsCorrectUserWithValidEmail()
3030
{
3131
var context = new MongoTestContext(GetConnection());
3232
var store = new MongoUserOnlyStore<MongoTestUser>(context);
3333

34-
var result = await store.FindByEmailAsync("[email protected]");
34+
var result = await store.FindByEmailAsync("[email protected]", TestContext.Current.CancellationToken);
3535

3636
result.Should().NotBeNull();
3737
result.UserName.Should().Be("User Name3");
@@ -42,10 +42,10 @@ public async Task FindsTrackedEntityWithValidEmail()
4242
{
4343
var context = new MongoTestContext(GetConnection());
4444
var store = new MongoUserOnlyStore<MongoTestUser>(context);
45-
var tracked = await store.FindByIdAsync(TestIds.UserId2);
45+
var tracked = await store.FindByIdAsync(TestIds.UserId2, TestContext.Current.CancellationToken);
4646
tracked.CustomData = "updated";
4747

48-
var result = await store.FindByEmailAsync("[email protected]");
48+
var result = await store.FindByEmailAsync("[email protected]", TestContext.Current.CancellationToken);
4949

5050
result.Should().BeSameAs(tracked);
5151
result.CustomData.Should().Be("updated");
@@ -57,7 +57,7 @@ public async Task ReturnsNullWithInvalidEmail()
5757
var context = new MongoTestContext(GetConnection());
5858
var store = new MongoUserOnlyStore<MongoTestUser>(context);
5959

60-
var result = await store.FindByEmailAsync("none");
60+
var result = await store.FindByEmailAsync("none", TestContext.Current.CancellationToken);
6161

6262
result.Should().BeNull();
6363
}

0 commit comments

Comments
 (0)