Skip to content

Commit 035cd03

Browse files
Fix all cancellation token warnings for xUnit v3
Co-authored-by: JohnCampionJr <[email protected]>
1 parent 7003087 commit 035cd03

24 files changed

+123
-123
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -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: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,14 +29,14 @@ 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: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,9 @@ 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: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ public async Task FindsCorrectUserWithValidEmail()
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
}

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ public async Task FindsCorrectUserWithValidStringId()
3636
var context = new MongoTestContext(GetConnection());
3737
var store = new MongoUserOnlyStore<MongoTestUser>(context);
3838

39-
var result = await store.FindByIdAsync(TestIds.UserId2);
39+
var result = await store.FindByIdAsync(TestIds.UserId2, TestContext.Current.CancellationToken);
4040

4141
result.Should().NotBeNull();
4242
result.UserName.Should().Be("User Name2");
@@ -48,7 +48,7 @@ public async Task ReturnsNullWithInvalidStringId()
4848
var context = new MongoTestContext(GetConnection());
4949
var store = new MongoUserOnlyStore<MongoTestUser>(context);
5050

51-
var result = await store.FindByIdAsync("none");
51+
var result = await store.FindByIdAsync("none", TestContext.Current.CancellationToken);
5252

5353
result.Should().BeNull();
5454
}
@@ -59,7 +59,7 @@ public async Task FindsCorrectUserWithValidIntId()
5959
var context = new MongoTestContext(GetConnection());
6060
var store = new MongoUserOnlyStore<MongoTestUserInt, DbContext, int>(context);
6161

62-
var result = await store.FindByIdAsync("2000");
62+
var result = await store.FindByIdAsync("2000", TestContext.Current.CancellationToken);
6363

6464
result.Should().NotBeNull();
6565
result.UserName.Should().Be("User Name2");
@@ -71,7 +71,7 @@ public async Task ReturnsNullWithInvalidIntId()
7171
var context = new MongoTestContext(GetConnection());
7272
var store = new MongoUserOnlyStore<MongoTestUserInt, DbContext, int>(context);
7373

74-
var result = await store.FindByIdAsync("1234");
74+
var result = await store.FindByIdAsync("1234", TestContext.Current.CancellationToken);
7575

7676
result.Should().BeNull();
7777
}

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ public async Task GetsCorrectUserFromLogin()
5252
var context = new MongoTestContext(GetConnection());
5353
var store = new MongoUserOnlyStore<MongoTestUser>(context);
5454

55-
var user = await store.FindByLoginAsync("provider3", "provider-key");
55+
var user = await store.FindByLoginAsync("provider3", "provider-key", TestContext.Current.CancellationToken);
5656

5757
user.Should().NotBeNull();
5858
user.Id.Should().Be(TestIds.UserId2);
@@ -77,7 +77,7 @@ public async Task ReturnsNullFromNonExisting()
7777
var context = new MongoTestContext(GetConnection());
7878
var store = new MongoUserOnlyStore<MongoTestUser>(context);
7979

80-
var user = await store.FindByLoginAsync("provider5", "provider-key");
80+
var user = await store.FindByLoginAsync("provider5", "provider-key", TestContext.Current.CancellationToken);
8181

8282
user.Should().BeNull();
8383
}
@@ -88,7 +88,7 @@ public async Task ReturnsNullFromNull()
8888
var context = new MongoTestContext(GetConnection());
8989
var store = new MongoUserOnlyStore<MongoTestUser>(context);
9090

91-
var user = await store.FindByLoginAsync(null, "provider-key");
91+
var user = await store.FindByLoginAsync(null, "provider-key", TestContext.Current.CancellationToken);
9292

9393
user.Should().BeNull();
9494
}

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ public async Task FindsCorrectUserWithValidUserName()
3131
var context = new MongoTestContext(GetConnection());
3232
var store = new MongoUserOnlyStore<MongoTestUser>(context);
3333

34-
var result = await store.FindByNameAsync("USER NAME2");
34+
var result = await store.FindByNameAsync("USER NAME2", TestContext.Current.CancellationToken);
3535

3636
result.Should().NotBeNull();
3737
result.UserName.Should().Be("User Name2");
@@ -43,10 +43,10 @@ public async Task FindsTrackedEntityWithValidUserName()
4343
{
4444
var context = new MongoTestContext(GetConnection());
4545
var store = new MongoUserOnlyStore<MongoTestUser>(context);
46-
var tracked = await store.FindByIdAsync(TestIds.UserId2);
46+
var tracked = await store.FindByIdAsync(TestIds.UserId2, TestContext.Current.CancellationToken);
4747
tracked.CustomData = "updated";
4848

49-
var result = await store.FindByNameAsync("USER NAME2");
49+
var result = await store.FindByNameAsync("USER NAME2", TestContext.Current.CancellationToken);
5050

5151
result.Should().BeSameAs(tracked);
5252
result.CustomData.Should().Be("updated");
@@ -59,7 +59,7 @@ public async Task ReturnsNullWithInvalidUserName()
5959
var context = new MongoTestContext(GetConnection());
6060
var store = new MongoUserOnlyStore<MongoTestUser>(context);
6161

62-
var result = await store.FindByNameAsync("none");
62+
var result = await store.FindByNameAsync("none", TestContext.Current.CancellationToken);
6363

6464
result.Should().BeNull();
6565
}

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,9 @@ public async Task RetrievesClaimsFromUser()
3838
{
3939
var context = new MongoTestContext(GetConnection());
4040
var store = new MongoUserOnlyStore<MongoTestUser>(context);
41-
var user = await store.FindByIdAsync(TestIds.UserId1);
41+
var user = await store.FindByIdAsync(TestIds.UserId1, TestContext.Current.CancellationToken);
4242

43-
var claims = await store.GetClaimsAsync(user);
43+
var claims = await store.GetClaimsAsync(user, TestContext.Current.CancellationToken);
4444

4545
claims.Count.Should().Be(2);
4646
claims[0].Type.Should().Be("type");

0 commit comments

Comments
 (0)