diff --git a/.github/workflows/dotnet-test.yml b/.github/workflows/dotnet-test.yml index a91aabf..2c9a066 100644 --- a/.github/workflows/dotnet-test.yml +++ b/.github/workflows/dotnet-test.yml @@ -5,6 +5,7 @@ on: branches: [main] pull_request: branches: [main] + workflow_dispatch: jobs: build: diff --git a/Net9MultiTenant/Pages/NoTenant.cshtml.cs b/Net9MultiTenant/Pages/NoTenant.cshtml.cs index cca0e8d..a1e06ba 100644 --- a/Net9MultiTenant/Pages/NoTenant.cshtml.cs +++ b/Net9MultiTenant/Pages/NoTenant.cshtml.cs @@ -11,7 +11,7 @@ namespace Net9MultiTenant.Pages public class NoTenantModel() : PageModel { [ExcludeFromMultiTenantResolution] - public async Task OnGet() + public void OnGet() { } diff --git a/tests/MongoFramework.AspNetCore.Identity.Tests/MongoEntityFramework.AspNetCore.Identity.Tests.csproj b/tests/MongoFramework.AspNetCore.Identity.Tests/MongoEntityFramework.AspNetCore.Identity.Tests.csproj index 4975a62..c1629da 100644 --- a/tests/MongoFramework.AspNetCore.Identity.Tests/MongoEntityFramework.AspNetCore.Identity.Tests.csproj +++ b/tests/MongoFramework.AspNetCore.Identity.Tests/MongoEntityFramework.AspNetCore.Identity.Tests.csproj @@ -19,15 +19,11 @@ - + all runtime; build; native; contentfiles; analyzers; buildtransitive - - all - runtime; build; native; contentfiles; analyzers; buildtransitive - diff --git a/tests/MongoFramework.AspNetCore.Identity.Tests/MongoIdentityContextsTests.cs b/tests/MongoFramework.AspNetCore.Identity.Tests/MongoIdentityContextsTests.cs index 12f8241..b17d837 100644 --- a/tests/MongoFramework.AspNetCore.Identity.Tests/MongoIdentityContextsTests.cs +++ b/tests/MongoFramework.AspNetCore.Identity.Tests/MongoIdentityContextsTests.cs @@ -22,7 +22,7 @@ public class MongoIdentityContextsTests : TestBase, IAsyncLifetime public MongoIdentityContextsTests() : base("MongoIdentityContexts") { } - public async Task InitializeAsync() + public async ValueTask InitializeAsync() { var context = new MongoIdentityDbContext(GetConnection()); var store = new MongoUserStore(context); @@ -40,7 +40,7 @@ public async Task InitializeAsync() } - public Task DisposeAsync() => Task.CompletedTask; + public ValueTask DisposeAsync() => ValueTask.CompletedTask; [Fact] public void ContextWithRolesLoadsRoles() diff --git a/tests/MongoFramework.AspNetCore.Identity.Tests/MongoRoleStoreTests.cs b/tests/MongoFramework.AspNetCore.Identity.Tests/MongoRoleStoreTests.cs index 8f408c0..38159f6 100644 --- a/tests/MongoFramework.AspNetCore.Identity.Tests/MongoRoleStoreTests.cs +++ b/tests/MongoFramework.AspNetCore.Identity.Tests/MongoRoleStoreTests.cs @@ -12,7 +12,7 @@ public class MongoRoleStoreTests : TestBase, IAsyncLifetime public MongoRoleStoreTests() : base("MongoRoleStore") { } - public async Task InitializeAsync() + public async ValueTask InitializeAsync() { var context = new MongoTestContext(GetConnection()); var store = new MongoUserStore(context); @@ -30,7 +30,7 @@ public async Task InitializeAsync() } - public Task DisposeAsync() => Task.CompletedTask; + public ValueTask DisposeAsync() => ValueTask.CompletedTask; [Fact] public void ConstructorUsesMongo() @@ -71,7 +71,7 @@ public async Task GetNormalizedRoleReturnsCorrect() var store = new MongoRoleStore, DbContext, int>(context); var role = new MongoIdentityRole { Name = "testrole", NormalizedName = "TESTROLE" }; - var name = await store.GetNormalizedRoleNameAsync(role); + var name = await store.GetNormalizedRoleNameAsync(role, TestContext.Current.CancellationToken); name.Should().Be("TESTROLE"); } diff --git a/tests/MongoFramework.AspNetCore.Identity.Tests/MongoUserOnlyStoreTests/AddClaims.cs b/tests/MongoFramework.AspNetCore.Identity.Tests/MongoUserOnlyStoreTests/AddClaims.cs index b80393e..b299b5d 100644 --- a/tests/MongoFramework.AspNetCore.Identity.Tests/MongoUserOnlyStoreTests/AddClaims.cs +++ b/tests/MongoFramework.AspNetCore.Identity.Tests/MongoUserOnlyStoreTests/AddClaims.cs @@ -14,7 +14,7 @@ public class AddClaims : TestBase, IAsyncLifetime public AddClaims() : base("MongoUserOnlyStore-AddClaims") { } - public async Task InitializeAsync() + public async ValueTask InitializeAsync() { var context = new MongoTestContext(GetConnection()); var store = new MongoUserOnlyStore(context); @@ -22,21 +22,21 @@ public async Task InitializeAsync() await store.CreateAsync(MongoTestUser.First); } - public Task DisposeAsync() => Task.CompletedTask; + public ValueTask DisposeAsync() => ValueTask.CompletedTask; [Fact] public async Task UpdatesUser() { var context = new MongoTestContext(GetConnection()); var store = new MongoUserOnlyStore(context); - var user = await store.FindByIdAsync(TestIds.UserId1); + var user = await store.FindByIdAsync(TestIds.UserId1, TestContext.Current.CancellationToken); await store.AddClaimsAsync(user, new[] { new Claim("type","value"), new Claim("type2", "value2") - }); + }, TestContext.Current.CancellationToken); user.Claims.Count.Should().Be(2); user.Claims[0].ClaimType.Should().Be("type"); @@ -47,20 +47,20 @@ public async Task SavesData() { var context = new MongoTestContext(GetConnection()); var store = new MongoUserOnlyStore(context); - var user = await store.FindByIdAsync(TestIds.UserId1); + var user = await store.FindByIdAsync(TestIds.UserId1, TestContext.Current.CancellationToken); await store.AddClaimsAsync(user, new[] { new Claim("type","value"), new Claim("type2", "value2") - }); + }, TestContext.Current.CancellationToken); - await store.UpdateAsync(user); + await store.UpdateAsync(user, TestContext.Current.CancellationToken); context = new MongoTestContext(GetConnection()); store = new MongoUserOnlyStore(context); - user = await store.FindByIdAsync(TestIds.UserId1); + user = await store.FindByIdAsync(TestIds.UserId1, TestContext.Current.CancellationToken); user.Claims.Count.Should().Be(2); user.Claims[0].ClaimType.Should().Be("type"); diff --git a/tests/MongoFramework.AspNetCore.Identity.Tests/MongoUserOnlyStoreTests/AddLogin.cs b/tests/MongoFramework.AspNetCore.Identity.Tests/MongoUserOnlyStoreTests/AddLogin.cs index 478b784..f9ad1cd 100644 --- a/tests/MongoFramework.AspNetCore.Identity.Tests/MongoUserOnlyStoreTests/AddLogin.cs +++ b/tests/MongoFramework.AspNetCore.Identity.Tests/MongoUserOnlyStoreTests/AddLogin.cs @@ -14,7 +14,7 @@ public class AddLogin : TestBase, IAsyncLifetime public AddLogin() : base("MongoUserOnlyStore-AddLogin") { } - public async Task InitializeAsync() + public async ValueTask InitializeAsync() { var context = new MongoTestContext(GetConnection()); var store = new MongoUserOnlyStore(context); @@ -24,16 +24,16 @@ public async Task InitializeAsync() await store.CreateAsync(MongoTestUser.Third); } - public Task DisposeAsync() => Task.CompletedTask; + public ValueTask DisposeAsync() => ValueTask.CompletedTask; [Fact] public async Task UpdatesUser() { var context = new MongoTestContext(GetConnection()); var store = new MongoUserOnlyStore(context); - var user = await store.FindByIdAsync(TestIds.UserId1); + var user = await store.FindByIdAsync(TestIds.UserId1, TestContext.Current.CancellationToken); - await store.AddLoginAsync(user, new UserLoginInfo("provider1", "provider-key", "Login Provider")); + await store.AddLoginAsync(user, new UserLoginInfo("provider1", "provider-key", "Login Provider"), TestContext.Current.CancellationToken); user.Logins.Count.Should().Be(1); user.Logins[0].LoginProvider.Should().Be("provider1"); @@ -44,14 +44,14 @@ public async Task SavesData() { var context = new MongoTestContext(GetConnection()); var store = new MongoUserOnlyStore(context); - var user = await store.FindByIdAsync(TestIds.UserId1); + var user = await store.FindByIdAsync(TestIds.UserId1, TestContext.Current.CancellationToken); - await store.AddLoginAsync(user, new UserLoginInfo("provider1", "provider-key", "Login Provider")); - await store.UpdateAsync(user); + await store.AddLoginAsync(user, new UserLoginInfo("provider1", "provider-key", "Login Provider"), TestContext.Current.CancellationToken); + await store.UpdateAsync(user, TestContext.Current.CancellationToken); context = new MongoTestContext(GetConnection()); store = new MongoUserOnlyStore(context); - user = await store.FindByIdAsync(TestIds.UserId1); + user = await store.FindByIdAsync(TestIds.UserId1, TestContext.Current.CancellationToken); user.Logins.Count.Should().Be(1); user.Logins[0].LoginProvider.Should().Be("provider1"); diff --git a/tests/MongoFramework.AspNetCore.Identity.Tests/MongoUserOnlyStoreTests/CreateUser.cs b/tests/MongoFramework.AspNetCore.Identity.Tests/MongoUserOnlyStoreTests/CreateUser.cs index 11e8989..6efd6fb 100644 --- a/tests/MongoFramework.AspNetCore.Identity.Tests/MongoUserOnlyStoreTests/CreateUser.cs +++ b/tests/MongoFramework.AspNetCore.Identity.Tests/MongoUserOnlyStoreTests/CreateUser.cs @@ -20,7 +20,7 @@ public async Task ReturnsSuccessWithStringId() var context = new MongoTestContext(GetConnection()); var store = new MongoUserOnlyStore(context); - var result = await store.CreateAsync(MongoTestUser.First); + var result = await store.CreateAsync(MongoTestUser.First, TestContext.Current.CancellationToken); result.Should().Be(IdentityResult.Success); } @@ -31,7 +31,7 @@ public async Task CreatesDataWithStringId() var context = new MongoTestContext(GetConnection()); var store = new MongoUserOnlyStore(context); - await store.CreateAsync(MongoTestUser.First); + await store.CreateAsync(MongoTestUser.First, TestContext.Current.CancellationToken); context.TestUsers.Any().Should().BeTrue(); context.TestUsers.Count().Should().Be(1); @@ -46,7 +46,7 @@ public async Task DoesNotCreatesDataWithAutoSaveOff() store.AutoSaveChanges = false; - await store.CreateAsync(MongoTestUser.First); + await store.CreateAsync(MongoTestUser.First, TestContext.Current.CancellationToken); context.TestUsers.Any().Should().BeFalse(); context.TestUsers.Count().Should().Be(0); @@ -59,7 +59,7 @@ public async Task ReturnsSuccessWithIntId() var context = new MongoTestContext(GetConnection()); var store = new MongoUserOnlyStore(context); - var result = await store.CreateAsync(MongoTestUserInt.First); + var result = await store.CreateAsync(MongoTestUserInt.First, TestContext.Current.CancellationToken); result.Should().Be(IdentityResult.Success); } @@ -70,7 +70,7 @@ public async Task CreatesDataWithIntId() var context = new MongoTestContext(GetConnection()); var store = new MongoUserOnlyStore(context); - await store.CreateAsync(MongoTestUserInt.First); + await store.CreateAsync(MongoTestUserInt.First, TestContext.Current.CancellationToken); context.TestUsersInt.Any().Should().BeTrue(); context.TestUsersInt.Count().Should().Be(1); diff --git a/tests/MongoFramework.AspNetCore.Identity.Tests/MongoUserOnlyStoreTests/DeleteUser.cs b/tests/MongoFramework.AspNetCore.Identity.Tests/MongoUserOnlyStoreTests/DeleteUser.cs index 842087d..5d99697 100644 --- a/tests/MongoFramework.AspNetCore.Identity.Tests/MongoUserOnlyStoreTests/DeleteUser.cs +++ b/tests/MongoFramework.AspNetCore.Identity.Tests/MongoUserOnlyStoreTests/DeleteUser.cs @@ -19,15 +19,15 @@ public async Task DeletesDataWithValidUser() { var context = new MongoTestContext(GetConnection()); var store = new MongoUserOnlyStore(context); - await store.CreateAsync(MongoTestUser.First); + await store.CreateAsync(MongoTestUser.First, TestContext.Current.CancellationToken); context.TestUsers.Any().Should().BeTrue(); context = new MongoTestContext(GetConnection()); store = new MongoUserOnlyStore(context); - var user = await context.TestUsers.FirstOrDefaultAsync(); + var user = await context.TestUsers.FirstOrDefaultAsync(TestContext.Current.CancellationToken); - await store.DeleteAsync(user); + await store.DeleteAsync(user, TestContext.Current.CancellationToken); context.TestUsers.Any().Should().BeFalse(); } @@ -37,15 +37,15 @@ public async Task ReturnsSuccessWithValidUser() { var context = new MongoTestContext(GetConnection()); var store = new MongoUserOnlyStore(context); - await store.CreateAsync(MongoTestUser.First); + await store.CreateAsync(MongoTestUser.First, TestContext.Current.CancellationToken); context.TestUsers.Any().Should().BeTrue(); context = new MongoTestContext(GetConnection()); store = new MongoUserOnlyStore(context); - var user = await context.TestUsers.FirstOrDefaultAsync(); + var user = await context.TestUsers.FirstOrDefaultAsync(TestContext.Current.CancellationToken); - var result = await store.DeleteAsync(user); + var result = await store.DeleteAsync(user, TestContext.Current.CancellationToken); result.Should().Be(IdentityResult.Success); } diff --git a/tests/MongoFramework.AspNetCore.Identity.Tests/MongoUserOnlyStoreTests/FindByEmail.cs b/tests/MongoFramework.AspNetCore.Identity.Tests/MongoUserOnlyStoreTests/FindByEmail.cs index be42d00..a0c77f2 100644 --- a/tests/MongoFramework.AspNetCore.Identity.Tests/MongoUserOnlyStoreTests/FindByEmail.cs +++ b/tests/MongoFramework.AspNetCore.Identity.Tests/MongoUserOnlyStoreTests/FindByEmail.cs @@ -13,7 +13,7 @@ public class FindByEmail : TestBase, IAsyncLifetime public FindByEmail() : base("MongoUserOnlyStore-FindByEmail") { } - public async Task InitializeAsync() + public async ValueTask InitializeAsync() { var context = new MongoTestContext(GetConnection()); var store = new MongoUserOnlyStore(context); @@ -23,7 +23,7 @@ public async Task InitializeAsync() await store.CreateAsync(MongoTestUser.Third); } - public Task DisposeAsync() => Task.CompletedTask; + public ValueTask DisposeAsync() => ValueTask.CompletedTask; [Fact] public async Task FindsCorrectUserWithValidEmail() @@ -31,7 +31,7 @@ public async Task FindsCorrectUserWithValidEmail() var context = new MongoTestContext(GetConnection()); var store = new MongoUserOnlyStore(context); - var result = await store.FindByEmailAsync("TEST3@TESTING.COM"); + var result = await store.FindByEmailAsync("TEST3@TESTING.COM", TestContext.Current.CancellationToken); result.Should().NotBeNull(); result.UserName.Should().Be("User Name3"); @@ -42,10 +42,10 @@ public async Task FindsTrackedEntityWithValidEmail() { var context = new MongoTestContext(GetConnection()); var store = new MongoUserOnlyStore(context); - var tracked = await store.FindByIdAsync(TestIds.UserId2); + var tracked = await store.FindByIdAsync(TestIds.UserId2, TestContext.Current.CancellationToken); tracked.CustomData = "updated"; - var result = await store.FindByEmailAsync("TEST2@TESTING.COM"); + var result = await store.FindByEmailAsync("TEST2@TESTING.COM", TestContext.Current.CancellationToken); result.Should().BeSameAs(tracked); result.CustomData.Should().Be("updated"); @@ -57,7 +57,7 @@ public async Task ReturnsNullWithInvalidEmail() var context = new MongoTestContext(GetConnection()); var store = new MongoUserOnlyStore(context); - var result = await store.FindByEmailAsync("none"); + var result = await store.FindByEmailAsync("none", TestContext.Current.CancellationToken); result.Should().BeNull(); } diff --git a/tests/MongoFramework.AspNetCore.Identity.Tests/MongoUserOnlyStoreTests/FindById.cs b/tests/MongoFramework.AspNetCore.Identity.Tests/MongoUserOnlyStoreTests/FindById.cs index b1329df..df52d17 100644 --- a/tests/MongoFramework.AspNetCore.Identity.Tests/MongoUserOnlyStoreTests/FindById.cs +++ b/tests/MongoFramework.AspNetCore.Identity.Tests/MongoUserOnlyStoreTests/FindById.cs @@ -14,7 +14,7 @@ public class FindById : TestBase, IAsyncLifetime public FindById() : base("MongoUserOnlyStore-FindById") { } - public async Task InitializeAsync() + public async ValueTask InitializeAsync() { var context = new MongoTestContext(GetConnection()); var store = new MongoUserOnlyStore(context); @@ -28,7 +28,7 @@ public async Task InitializeAsync() await store2.CreateAsync(MongoTestUserInt.Third); } - public Task DisposeAsync() => Task.CompletedTask; + public ValueTask DisposeAsync() => ValueTask.CompletedTask; [Fact] public async Task FindsCorrectUserWithValidStringId() @@ -36,7 +36,7 @@ public async Task FindsCorrectUserWithValidStringId() var context = new MongoTestContext(GetConnection()); var store = new MongoUserOnlyStore(context); - var result = await store.FindByIdAsync(TestIds.UserId2); + var result = await store.FindByIdAsync(TestIds.UserId2, TestContext.Current.CancellationToken); result.Should().NotBeNull(); result.UserName.Should().Be("User Name2"); @@ -48,7 +48,7 @@ public async Task ReturnsNullWithInvalidStringId() var context = new MongoTestContext(GetConnection()); var store = new MongoUserOnlyStore(context); - var result = await store.FindByIdAsync("none"); + var result = await store.FindByIdAsync("none", TestContext.Current.CancellationToken); result.Should().BeNull(); } @@ -59,7 +59,7 @@ public async Task FindsCorrectUserWithValidIntId() var context = new MongoTestContext(GetConnection()); var store = new MongoUserOnlyStore(context); - var result = await store.FindByIdAsync("2000"); + var result = await store.FindByIdAsync("2000", TestContext.Current.CancellationToken); result.Should().NotBeNull(); result.UserName.Should().Be("User Name2"); @@ -71,7 +71,7 @@ public async Task ReturnsNullWithInvalidIntId() var context = new MongoTestContext(GetConnection()); var store = new MongoUserOnlyStore(context); - var result = await store.FindByIdAsync("1234"); + var result = await store.FindByIdAsync("1234", TestContext.Current.CancellationToken); result.Should().BeNull(); } diff --git a/tests/MongoFramework.AspNetCore.Identity.Tests/MongoUserOnlyStoreTests/FindByLogin.cs b/tests/MongoFramework.AspNetCore.Identity.Tests/MongoUserOnlyStoreTests/FindByLogin.cs index 8c01b7f..605ebd9 100644 --- a/tests/MongoFramework.AspNetCore.Identity.Tests/MongoUserOnlyStoreTests/FindByLogin.cs +++ b/tests/MongoFramework.AspNetCore.Identity.Tests/MongoUserOnlyStoreTests/FindByLogin.cs @@ -25,7 +25,7 @@ public async Task> ExposeFindUserLoginAsync(string use public FindByLogin() : base("MongoUserOnlyStore-FindByLogin") { } - public async Task InitializeAsync() + public async ValueTask InitializeAsync() { var context = new MongoTestContext(GetConnection()); var store = new MongoUserOnlyStore(context); @@ -44,7 +44,7 @@ public async Task InitializeAsync() } - public Task DisposeAsync() => Task.CompletedTask; + public ValueTask DisposeAsync() => ValueTask.CompletedTask; [Fact] public async Task GetsCorrectUserFromLogin() @@ -52,7 +52,7 @@ public async Task GetsCorrectUserFromLogin() var context = new MongoTestContext(GetConnection()); var store = new MongoUserOnlyStore(context); - var user = await store.FindByLoginAsync("provider3", "provider-key"); + var user = await store.FindByLoginAsync("provider3", "provider-key", TestContext.Current.CancellationToken); user.Should().NotBeNull(); user.Id.Should().Be(TestIds.UserId2); @@ -77,7 +77,7 @@ public async Task ReturnsNullFromNonExisting() var context = new MongoTestContext(GetConnection()); var store = new MongoUserOnlyStore(context); - var user = await store.FindByLoginAsync("provider5", "provider-key"); + var user = await store.FindByLoginAsync("provider5", "provider-key", TestContext.Current.CancellationToken); user.Should().BeNull(); } @@ -88,7 +88,7 @@ public async Task ReturnsNullFromNull() var context = new MongoTestContext(GetConnection()); var store = new MongoUserOnlyStore(context); - var user = await store.FindByLoginAsync(null, "provider-key"); + var user = await store.FindByLoginAsync(null, "provider-key", TestContext.Current.CancellationToken); user.Should().BeNull(); } diff --git a/tests/MongoFramework.AspNetCore.Identity.Tests/MongoUserOnlyStoreTests/FindByName.cs b/tests/MongoFramework.AspNetCore.Identity.Tests/MongoUserOnlyStoreTests/FindByName.cs index ba0285f..fb60826 100644 --- a/tests/MongoFramework.AspNetCore.Identity.Tests/MongoUserOnlyStoreTests/FindByName.cs +++ b/tests/MongoFramework.AspNetCore.Identity.Tests/MongoUserOnlyStoreTests/FindByName.cs @@ -13,7 +13,7 @@ public class FindByName : TestBase, IAsyncLifetime public FindByName() : base("MongoUserOnlyStore-FindByName") { } - public async Task InitializeAsync() + public async ValueTask InitializeAsync() { var context = new MongoTestContext(GetConnection()); var store = new MongoUserOnlyStore(context); @@ -23,7 +23,7 @@ public async Task InitializeAsync() await store.CreateAsync(MongoTestUser.Third); } - public Task DisposeAsync() => Task.CompletedTask; + public ValueTask DisposeAsync() => ValueTask.CompletedTask; [Fact] public async Task FindsCorrectUserWithValidUserName() @@ -31,7 +31,7 @@ public async Task FindsCorrectUserWithValidUserName() var context = new MongoTestContext(GetConnection()); var store = new MongoUserOnlyStore(context); - var result = await store.FindByNameAsync("USER NAME2"); + var result = await store.FindByNameAsync("USER NAME2", TestContext.Current.CancellationToken); result.Should().NotBeNull(); result.UserName.Should().Be("User Name2"); @@ -43,10 +43,10 @@ public async Task FindsTrackedEntityWithValidUserName() { var context = new MongoTestContext(GetConnection()); var store = new MongoUserOnlyStore(context); - var tracked = await store.FindByIdAsync(TestIds.UserId2); + var tracked = await store.FindByIdAsync(TestIds.UserId2, TestContext.Current.CancellationToken); tracked.CustomData = "updated"; - var result = await store.FindByNameAsync("USER NAME2"); + var result = await store.FindByNameAsync("USER NAME2", TestContext.Current.CancellationToken); result.Should().BeSameAs(tracked); result.CustomData.Should().Be("updated"); @@ -59,7 +59,7 @@ public async Task ReturnsNullWithInvalidUserName() var context = new MongoTestContext(GetConnection()); var store = new MongoUserOnlyStore(context); - var result = await store.FindByNameAsync("none"); + var result = await store.FindByNameAsync("none", TestContext.Current.CancellationToken); result.Should().BeNull(); } diff --git a/tests/MongoFramework.AspNetCore.Identity.Tests/MongoUserOnlyStoreTests/GetClaims.cs b/tests/MongoFramework.AspNetCore.Identity.Tests/MongoUserOnlyStoreTests/GetClaims.cs index 8b06401..6a958d8 100644 --- a/tests/MongoFramework.AspNetCore.Identity.Tests/MongoUserOnlyStoreTests/GetClaims.cs +++ b/tests/MongoFramework.AspNetCore.Identity.Tests/MongoUserOnlyStoreTests/GetClaims.cs @@ -14,7 +14,7 @@ public class GetClaims : TestBase, IAsyncLifetime public GetClaims() : base("MongoUserOnlyStore-GetClaims") { } - public async Task InitializeAsync() + public async ValueTask InitializeAsync() { var context = new MongoTestContext(GetConnection()); var store = new MongoUserOnlyStore(context); @@ -31,16 +31,16 @@ await store.AddClaimsAsync(user, } - public Task DisposeAsync() => Task.CompletedTask; + public ValueTask DisposeAsync() => ValueTask.CompletedTask; [Fact] public async Task RetrievesClaimsFromUser() { var context = new MongoTestContext(GetConnection()); var store = new MongoUserOnlyStore(context); - var user = await store.FindByIdAsync(TestIds.UserId1); + var user = await store.FindByIdAsync(TestIds.UserId1, TestContext.Current.CancellationToken); - var claims = await store.GetClaimsAsync(user); + var claims = await store.GetClaimsAsync(user, TestContext.Current.CancellationToken); claims.Count.Should().Be(2); claims[0].Type.Should().Be("type"); diff --git a/tests/MongoFramework.AspNetCore.Identity.Tests/MongoUserOnlyStoreTests/GetLogins.cs b/tests/MongoFramework.AspNetCore.Identity.Tests/MongoUserOnlyStoreTests/GetLogins.cs index 35ecc91..50d5ab7 100644 --- a/tests/MongoFramework.AspNetCore.Identity.Tests/MongoUserOnlyStoreTests/GetLogins.cs +++ b/tests/MongoFramework.AspNetCore.Identity.Tests/MongoUserOnlyStoreTests/GetLogins.cs @@ -14,7 +14,7 @@ public class GetLogins : TestBase, IAsyncLifetime public GetLogins() : base("MongoUserOnlyStore-GetLogins") { } - public async Task InitializeAsync() + public async ValueTask InitializeAsync() { var context = new MongoTestContext(GetConnection()); var store = new MongoUserOnlyStore(context); @@ -27,16 +27,16 @@ public async Task InitializeAsync() } - public Task DisposeAsync() => Task.CompletedTask; + public ValueTask DisposeAsync() => ValueTask.CompletedTask; [Fact] public async Task RetrieveLoginsFromUser() { var context = new MongoTestContext(GetConnection()); var store = new MongoUserOnlyStore(context); - var user = await store.FindByIdAsync(TestIds.UserId1); + var user = await store.FindByIdAsync(TestIds.UserId1, TestContext.Current.CancellationToken); - var logins = await store.GetLoginsAsync(user); + var logins = await store.GetLoginsAsync(user, TestContext.Current.CancellationToken); logins.Count.Should().Be(2); logins[0].LoginProvider.Should().Be("provider1"); diff --git a/tests/MongoFramework.AspNetCore.Identity.Tests/MongoUserOnlyStoreTests/GetToken.cs b/tests/MongoFramework.AspNetCore.Identity.Tests/MongoUserOnlyStoreTests/GetToken.cs index da2fb57..dc4169c 100644 --- a/tests/MongoFramework.AspNetCore.Identity.Tests/MongoUserOnlyStoreTests/GetToken.cs +++ b/tests/MongoFramework.AspNetCore.Identity.Tests/MongoUserOnlyStoreTests/GetToken.cs @@ -14,7 +14,7 @@ public class GetToken : TestBase, IAsyncLifetime public GetToken() : base("MongoUserOnlyStore-GetToken") { } - public async Task InitializeAsync() + public async ValueTask InitializeAsync() { var context = new MongoTestContext(GetConnection()); @@ -27,17 +27,17 @@ public async Task InitializeAsync() await store.UpdateAsync(user); } - public Task DisposeAsync() => Task.CompletedTask; + public ValueTask DisposeAsync() => ValueTask.CompletedTask; [Fact] public async Task RetrieveLoginsFromUser() { var context = new MongoTestContext(GetConnection()); var store = new MongoUserOnlyStore(context); - var user = await store.FindByIdAsync(TestIds.UserId1); + var user = await store.FindByIdAsync(TestIds.UserId1, TestContext.Current.CancellationToken); - var token1 = await store.GetTokenAsync(user, "provider1", "name1", default); - var token2 = await store.GetTokenAsync(user, "provider2", "name2", default); + var token1 = await store.GetTokenAsync(user, "provider1", "name1", TestContext.Current.CancellationToken); + var token2 = await store.GetTokenAsync(user, "provider2", "name2", TestContext.Current.CancellationToken); token1.Should().Be("token-value1"); token2.Should().Be("token-value2"); diff --git a/tests/MongoFramework.AspNetCore.Identity.Tests/MongoUserOnlyStoreTests/GetUsersForClaim.cs b/tests/MongoFramework.AspNetCore.Identity.Tests/MongoUserOnlyStoreTests/GetUsersForClaim.cs index 583af28..b094431 100644 --- a/tests/MongoFramework.AspNetCore.Identity.Tests/MongoUserOnlyStoreTests/GetUsersForClaim.cs +++ b/tests/MongoFramework.AspNetCore.Identity.Tests/MongoUserOnlyStoreTests/GetUsersForClaim.cs @@ -14,7 +14,7 @@ public class GetUsersForClaim : TestBase, IAsyncLifetime public GetUsersForClaim() : base("MongoUserOnlyStore-GetUsersForClaim") { } - public async Task InitializeAsync() + public async ValueTask InitializeAsync() { var context = new MongoTestContext(GetConnection()); var store = new MongoUserOnlyStore(context); @@ -49,7 +49,7 @@ await store.AddClaimsAsync(user, } - public Task DisposeAsync() => Task.CompletedTask; + public ValueTask DisposeAsync() => ValueTask.CompletedTask; [Fact] public async Task RetrieveUsersForClaim() @@ -57,8 +57,8 @@ public async Task RetrieveUsersForClaim() var context = new MongoTestContext(GetConnection()); var store = new MongoUserOnlyStore(context); - var users = await store.GetUsersForClaimAsync(new Claim("type", "value")); - var users2 = await store.GetUsersForClaimAsync(new Claim("type2", "value2")); + var users = await store.GetUsersForClaimAsync(new Claim("type", "value"), TestContext.Current.CancellationToken); + var users2 = await store.GetUsersForClaimAsync(new Claim("type2", "value2"), TestContext.Current.CancellationToken); users.Count.Should().Be(3); users2.Count.Should().Be(2); diff --git a/tests/MongoFramework.AspNetCore.Identity.Tests/MongoUserOnlyStoreTests/RemoveClaim.cs b/tests/MongoFramework.AspNetCore.Identity.Tests/MongoUserOnlyStoreTests/RemoveClaim.cs index a144a8a..92b12be 100644 --- a/tests/MongoFramework.AspNetCore.Identity.Tests/MongoUserOnlyStoreTests/RemoveClaim.cs +++ b/tests/MongoFramework.AspNetCore.Identity.Tests/MongoUserOnlyStoreTests/RemoveClaim.cs @@ -14,7 +14,7 @@ public class RemoveClaim : TestBase, IAsyncLifetime public RemoveClaim() : base("MongoUserOnlyStore-RemoveClaim") { } - public async Task InitializeAsync() + public async ValueTask InitializeAsync() { var context = new MongoTestContext(GetConnection()); var store = new MongoUserOnlyStore(context); @@ -31,18 +31,18 @@ await store.AddClaimsAsync(user, } - public Task DisposeAsync() => Task.CompletedTask; + public ValueTask DisposeAsync() => ValueTask.CompletedTask; [Fact] public async Task RemoveClaimWithExistingClaim() { var context = new MongoTestContext(GetConnection()); var store = new MongoUserOnlyStore(context); - var user = await store.FindByIdAsync(TestIds.UserId1); + var user = await store.FindByIdAsync(TestIds.UserId1, TestContext.Current.CancellationToken); - var claims = await store.GetClaimsAsync(user); + var claims = await store.GetClaimsAsync(user, TestContext.Current.CancellationToken); - await store.RemoveClaimsAsync(user, claims); + await store.RemoveClaimsAsync(user, claims, TestContext.Current.CancellationToken); user.Claims.Count.Should().Be(0); } @@ -52,12 +52,12 @@ public async Task RemoveClaimWithNewClaim() { var context = new MongoTestContext(GetConnection()); var store = new MongoUserOnlyStore(context); - var user = await store.FindByIdAsync(TestIds.UserId1); + var user = await store.FindByIdAsync(TestIds.UserId1, TestContext.Current.CancellationToken); await store.RemoveClaimsAsync(user, new[] { new Claim("type","value"), new Claim("type2", "value2") - }); + }, TestContext.Current.CancellationToken); user.Claims.Count.Should().Be(0); } @@ -67,16 +67,16 @@ public async Task SavesData() { var context = new MongoTestContext(GetConnection()); var store = new MongoUserOnlyStore(context); - var user = await store.FindByIdAsync(TestIds.UserId1); + var user = await store.FindByIdAsync(TestIds.UserId1, TestContext.Current.CancellationToken); - var claims = await store.GetClaimsAsync(user); + var claims = await store.GetClaimsAsync(user, TestContext.Current.CancellationToken); - await store.RemoveClaimsAsync(user, claims); - await store.UpdateAsync(user); + await store.RemoveClaimsAsync(user, claims, TestContext.Current.CancellationToken); + await store.UpdateAsync(user, TestContext.Current.CancellationToken); context = new MongoTestContext(GetConnection()); store = new MongoUserOnlyStore(context); - user = await store.FindByIdAsync(TestIds.UserId1); + user = await store.FindByIdAsync(TestIds.UserId1, TestContext.Current.CancellationToken); user.Claims.Count.Should().Be(0); } diff --git a/tests/MongoFramework.AspNetCore.Identity.Tests/MongoUserOnlyStoreTests/RemoveLogin.cs b/tests/MongoFramework.AspNetCore.Identity.Tests/MongoUserOnlyStoreTests/RemoveLogin.cs index ad4605d..b5c0ab9 100644 --- a/tests/MongoFramework.AspNetCore.Identity.Tests/MongoUserOnlyStoreTests/RemoveLogin.cs +++ b/tests/MongoFramework.AspNetCore.Identity.Tests/MongoUserOnlyStoreTests/RemoveLogin.cs @@ -14,7 +14,7 @@ public class RemoveLogin : TestBase, IAsyncLifetime public RemoveLogin() : base("MongoUserOnlyStore-RemoveLogin") { } - public async Task InitializeAsync() + public async ValueTask InitializeAsync() { var context = new MongoTestContext(GetConnection()); var store = new MongoUserOnlyStore(context); @@ -26,16 +26,16 @@ public async Task InitializeAsync() } - public Task DisposeAsync() => Task.CompletedTask; + public ValueTask DisposeAsync() => ValueTask.CompletedTask; [Fact] public async Task RemoveLoginWithExistingLogin() { var context = new MongoTestContext(GetConnection()); var store = new MongoUserOnlyStore(context); - var user = await store.FindByIdAsync(TestIds.UserId1); + var user = await store.FindByIdAsync(TestIds.UserId1, TestContext.Current.CancellationToken); - await store.RemoveLoginAsync(user, "provider1", "provider-key"); + await store.RemoveLoginAsync(user, "provider1", "provider-key", TestContext.Current.CancellationToken); user.Logins.Count.Should().Be(0); } @@ -45,14 +45,14 @@ public async Task SavesData() { var context = new MongoTestContext(GetConnection()); var store = new MongoUserOnlyStore(context); - var user = await store.FindByIdAsync(TestIds.UserId1); + var user = await store.FindByIdAsync(TestIds.UserId1, TestContext.Current.CancellationToken); - await store.RemoveLoginAsync(user, "provider1", "provider-key"); - await store.UpdateAsync(user); + await store.RemoveLoginAsync(user, "provider1", "provider-key", TestContext.Current.CancellationToken); + await store.UpdateAsync(user, TestContext.Current.CancellationToken); context = new MongoTestContext(GetConnection()); store = new MongoUserOnlyStore(context); - user = await store.FindByIdAsync(TestIds.UserId1); + user = await store.FindByIdAsync(TestIds.UserId1, TestContext.Current.CancellationToken); user.Logins.Count.Should().Be(0); } diff --git a/tests/MongoFramework.AspNetCore.Identity.Tests/MongoUserOnlyStoreTests/RemoveToken.cs b/tests/MongoFramework.AspNetCore.Identity.Tests/MongoUserOnlyStoreTests/RemoveToken.cs index de0bec0..51e3c02 100644 --- a/tests/MongoFramework.AspNetCore.Identity.Tests/MongoUserOnlyStoreTests/RemoveToken.cs +++ b/tests/MongoFramework.AspNetCore.Identity.Tests/MongoUserOnlyStoreTests/RemoveToken.cs @@ -14,7 +14,7 @@ public class RemoveToken : TestBase, IAsyncLifetime public RemoveToken() : base("MongoUserOnlyStore-RemoveToken") { } - public async Task InitializeAsync() + public async ValueTask InitializeAsync() { var context = new MongoTestContext(GetConnection()); @@ -27,16 +27,16 @@ public async Task InitializeAsync() await store.UpdateAsync(user); } - public Task DisposeAsync() => Task.CompletedTask; + public ValueTask DisposeAsync() => ValueTask.CompletedTask; [Fact] public async Task RemovesToken() { var context = new MongoTestContext(GetConnection()); var store = new MongoUserOnlyStore(context); - var user = await store.FindByIdAsync(TestIds.UserId1); + var user = await store.FindByIdAsync(TestIds.UserId1, TestContext.Current.CancellationToken); - await store.RemoveTokenAsync(user, "provider2", "name2", default); + await store.RemoveTokenAsync(user, "provider2", "name2", TestContext.Current.CancellationToken); user.Tokens.Count.Should().Be(1); } @@ -46,16 +46,16 @@ public async Task SavesData() { var context = new MongoTestContext(GetConnection()); var store = new MongoUserOnlyStore(context); - var user = await store.FindByIdAsync(TestIds.UserId1); + var user = await store.FindByIdAsync(TestIds.UserId1, TestContext.Current.CancellationToken); - await store.RemoveTokenAsync(user, "provider2", "name2", default); + await store.RemoveTokenAsync(user, "provider2", "name2", TestContext.Current.CancellationToken); - await store.UpdateAsync(user); + await store.UpdateAsync(user, TestContext.Current.CancellationToken); context = new MongoTestContext(GetConnection()); store = new MongoUserOnlyStore(context); - user = await store.FindByIdAsync(TestIds.UserId1); + user = await store.FindByIdAsync(TestIds.UserId1, TestContext.Current.CancellationToken); user.Tokens.Count.Should().Be(1); } diff --git a/tests/MongoFramework.AspNetCore.Identity.Tests/MongoUserOnlyStoreTests/ReplaceClaim.cs b/tests/MongoFramework.AspNetCore.Identity.Tests/MongoUserOnlyStoreTests/ReplaceClaim.cs index 22d2e09..32172f0 100644 --- a/tests/MongoFramework.AspNetCore.Identity.Tests/MongoUserOnlyStoreTests/ReplaceClaim.cs +++ b/tests/MongoFramework.AspNetCore.Identity.Tests/MongoUserOnlyStoreTests/ReplaceClaim.cs @@ -14,7 +14,7 @@ public class ReplaceClaim : TestBase, IAsyncLifetime public ReplaceClaim() : base("MongoUserOnlyStore-ReplaceClaim") { } - public async Task InitializeAsync() + public async ValueTask InitializeAsync() { var context = new MongoTestContext(GetConnection()); var store = new MongoUserOnlyStore(context); @@ -31,19 +31,19 @@ await store.AddClaimsAsync(user, } - public Task DisposeAsync() => Task.CompletedTask; + public ValueTask DisposeAsync() => ValueTask.CompletedTask; [Fact] public async Task ReplaceUsersClaim() { var context = new MongoTestContext(GetConnection()); var store = new MongoUserOnlyStore(context); - var user = await store.FindByIdAsync(TestIds.UserId1); + var user = await store.FindByIdAsync(TestIds.UserId1, TestContext.Current.CancellationToken); - var claims = await store.GetClaimsAsync(user); + var claims = await store.GetClaimsAsync(user, TestContext.Current.CancellationToken); var claim = claims[0]; - await store.ReplaceClaimAsync(user, claim, new Claim("new-type", "new-value")); + await store.ReplaceClaimAsync(user, claim, new Claim("new-type", "new-value"), TestContext.Current.CancellationToken); user.Claims[0].ClaimType.Should().Be("new-type"); user.Claims[0].ClaimValue.Should().Be("new-value"); @@ -54,18 +54,18 @@ public async Task SavesData() { var context = new MongoTestContext(GetConnection()); var store = new MongoUserOnlyStore(context); - var user = await store.FindByIdAsync(TestIds.UserId1); + var user = await store.FindByIdAsync(TestIds.UserId1, TestContext.Current.CancellationToken); - var claims = await store.GetClaimsAsync(user); + var claims = await store.GetClaimsAsync(user, TestContext.Current.CancellationToken); var claim = claims[0]; - await store.ReplaceClaimAsync(user, claim, new Claim("new-type", "new-value")); + await store.ReplaceClaimAsync(user, claim, new Claim("new-type", "new-value"), TestContext.Current.CancellationToken); - await store.UpdateAsync(user); + await store.UpdateAsync(user, TestContext.Current.CancellationToken); context = new MongoTestContext(GetConnection()); store = new MongoUserOnlyStore(context); - user = await store.FindByIdAsync(TestIds.UserId1); + user = await store.FindByIdAsync(TestIds.UserId1, TestContext.Current.CancellationToken); user.Claims.Count.Should().Be(2); user.Claims[0].ClaimType.Should().Be("new-type"); diff --git a/tests/MongoFramework.AspNetCore.Identity.Tests/MongoUserOnlyStoreTests/SetToken.cs b/tests/MongoFramework.AspNetCore.Identity.Tests/MongoUserOnlyStoreTests/SetToken.cs index 508a537..07d5986 100644 --- a/tests/MongoFramework.AspNetCore.Identity.Tests/MongoUserOnlyStoreTests/SetToken.cs +++ b/tests/MongoFramework.AspNetCore.Identity.Tests/MongoUserOnlyStoreTests/SetToken.cs @@ -14,7 +14,7 @@ public class SetToken : TestBase, IAsyncLifetime public SetToken() : base("MongoUserOnlyStore-SetToken") { } - public async Task InitializeAsync() + public async ValueTask InitializeAsync() { var context = new MongoTestContext(GetConnection()); var store = new MongoUserOnlyStore(context); @@ -22,16 +22,16 @@ public async Task InitializeAsync() await store.CreateAsync(MongoTestUser.First); } - public Task DisposeAsync() => Task.CompletedTask; + public ValueTask DisposeAsync() => ValueTask.CompletedTask; [Fact] public async Task UpdatesUserWithValidData() { var context = new MongoTestContext(GetConnection()); var store = new MongoUserOnlyStore(context); - var user = await store.FindByIdAsync(TestIds.UserId1); + var user = await store.FindByIdAsync(TestIds.UserId1, TestContext.Current.CancellationToken); - await store.SetTokenAsync(user, "provider", "name", "token-value", default); + await store.SetTokenAsync(user, "provider", "name", "token-value", TestContext.Current.CancellationToken); user.Tokens.Count.Should().Be(1); user.Tokens[0].Value.Should().Be("token-value"); @@ -42,15 +42,15 @@ public async Task SavesData() { var context = new MongoTestContext(GetConnection()); var store = new MongoUserOnlyStore(context); - var user = await store.FindByIdAsync(TestIds.UserId1); + var user = await store.FindByIdAsync(TestIds.UserId1, TestContext.Current.CancellationToken); - await store.SetTokenAsync(user, "provider", "name", "token-value", default); + await store.SetTokenAsync(user, "provider", "name", "token-value", TestContext.Current.CancellationToken); - await store.UpdateAsync(user); + await store.UpdateAsync(user, TestContext.Current.CancellationToken); context = new MongoTestContext(GetConnection()); store = new MongoUserOnlyStore(context); - user = await store.FindByIdAsync(TestIds.UserId1); + user = await store.FindByIdAsync(TestIds.UserId1, TestContext.Current.CancellationToken); user.Tokens.Count.Should().Be(1); user.Tokens[0].Value.Should().Be("token-value"); diff --git a/tests/MongoFramework.AspNetCore.Identity.Tests/MongoUserOnlyStoreTests/UpdateUser.cs b/tests/MongoFramework.AspNetCore.Identity.Tests/MongoUserOnlyStoreTests/UpdateUser.cs index ea7eae4..6905629 100644 --- a/tests/MongoFramework.AspNetCore.Identity.Tests/MongoUserOnlyStoreTests/UpdateUser.cs +++ b/tests/MongoFramework.AspNetCore.Identity.Tests/MongoUserOnlyStoreTests/UpdateUser.cs @@ -13,7 +13,7 @@ public class UpdateUser : TestBase, IAsyncLifetime public UpdateUser() : base("MongoUserOnlyStore-UpdateUser") { } - public async Task InitializeAsync() + public async ValueTask InitializeAsync() { var context = new MongoTestContext(GetConnection()); var store = new MongoUserOnlyStore(context); @@ -23,17 +23,17 @@ public async Task InitializeAsync() await store.CreateAsync(MongoTestUser.Third); } - public Task DisposeAsync() => Task.CompletedTask; + public ValueTask DisposeAsync() => ValueTask.CompletedTask; [Fact] public async Task ReturnsSuccess() { var context = new MongoTestContext(GetConnection()); var store = new MongoUserOnlyStore(context); - var user = await store.FindByIdAsync(TestIds.UserId1); + var user = await store.FindByIdAsync(TestIds.UserId1, TestContext.Current.CancellationToken); user.CustomData = "new-data"; - var result = await store.UpdateAsync(user); + var result = await store.UpdateAsync(user, TestContext.Current.CancellationToken); result.Should().Be(IdentityResult.Success); } @@ -44,10 +44,10 @@ public async Task SavesData() var context = new MongoTestContext(GetConnection()); var store = new MongoUserOnlyStore(context); - var user = await store.FindByIdAsync(TestIds.UserId1); + var user = await store.FindByIdAsync(TestIds.UserId1, TestContext.Current.CancellationToken); user.CustomData = "new-data"; - await store.UpdateAsync(user); + await store.UpdateAsync(user, TestContext.Current.CancellationToken); context.TestUsers.FirstOrDefault()?.CustomData.Should().Be("new-data"); } diff --git a/tests/MongoFramework.AspNetCore.Identity.Tests/MongoUserStoreTests/FindByEmail.cs b/tests/MongoFramework.AspNetCore.Identity.Tests/MongoUserStoreTests/FindByEmail.cs index e5d0c01..ab88d30 100644 --- a/tests/MongoFramework.AspNetCore.Identity.Tests/MongoUserStoreTests/FindByEmail.cs +++ b/tests/MongoFramework.AspNetCore.Identity.Tests/MongoUserStoreTests/FindByEmail.cs @@ -13,7 +13,7 @@ public class FindByEmail : TestBase, IAsyncLifetime public FindByEmail() : base("MongoUserStore-FindByEmail") { } - public async Task InitializeAsync() + public async ValueTask InitializeAsync() { var context = new MongoTestContext(GetConnection()); var store = new MongoUserStore(context); @@ -23,7 +23,7 @@ public async Task InitializeAsync() await store.CreateAsync(MongoTestUser.Third); } - public Task DisposeAsync() => Task.CompletedTask; + public ValueTask DisposeAsync() => ValueTask.CompletedTask; [Fact] public async Task FindsCorrectUserWithValidEmail() @@ -31,7 +31,7 @@ public async Task FindsCorrectUserWithValidEmail() var context = new MongoTestContext(GetConnection()); var store = new MongoUserStore(context); - var result = await store.FindByEmailAsync("TEST3@TESTING.COM"); + var result = await store.FindByEmailAsync("TEST3@TESTING.COM", TestContext.Current.CancellationToken); result.Should().NotBeNull(); result.UserName.Should().Be("User Name3"); @@ -42,10 +42,10 @@ public async Task FindsTrackedEntityWithValidEmail() { var context = new MongoTestContext(GetConnection()); var store = new MongoUserStore(context); - var tracked = await store.FindByIdAsync(TestIds.UserId2); + var tracked = await store.FindByIdAsync(TestIds.UserId2, TestContext.Current.CancellationToken); tracked.CustomData = "updated"; - var result = await store.FindByEmailAsync("TEST2@TESTING.COM"); + var result = await store.FindByEmailAsync("TEST2@TESTING.COM", TestContext.Current.CancellationToken); result.Should().BeSameAs(tracked); result.CustomData.Should().Be("updated"); @@ -57,7 +57,7 @@ public async Task ReturnsNullWithInvalidEmail() var context = new MongoTestContext(GetConnection()); var store = new MongoUserStore(context); - var result = await store.FindByEmailAsync("none"); + var result = await store.FindByEmailAsync("none", TestContext.Current.CancellationToken); result.Should().BeNull(); } diff --git a/tests/MongoFramework.AspNetCore.Identity.Tests/MongoUserStoreTests/FindByLogin.cs b/tests/MongoFramework.AspNetCore.Identity.Tests/MongoUserStoreTests/FindByLogin.cs index 4c9a9b6..dcac963 100644 --- a/tests/MongoFramework.AspNetCore.Identity.Tests/MongoUserStoreTests/FindByLogin.cs +++ b/tests/MongoFramework.AspNetCore.Identity.Tests/MongoUserStoreTests/FindByLogin.cs @@ -25,7 +25,7 @@ public async Task> ExposeFindUserLoginAsync(string use public FindByLogin() : base("MongoUserStore-FindByLogin") { } - public async Task InitializeAsync() + public async ValueTask InitializeAsync() { var context = new MongoTestContext(GetConnection()); var store = new MongoUserStore(context); @@ -44,7 +44,7 @@ public async Task InitializeAsync() } - public Task DisposeAsync() => Task.CompletedTask; + public ValueTask DisposeAsync() => ValueTask.CompletedTask; [Fact] public async Task GetsCorrectUserFromLogin() @@ -52,7 +52,7 @@ public async Task GetsCorrectUserFromLogin() var context = new MongoTestContext(GetConnection()); var store = new MongoUserStore(context); - var user = await store.FindByLoginAsync("provider3", "provider-key"); + var user = await store.FindByLoginAsync("provider3", "provider-key", TestContext.Current.CancellationToken); user.Should().NotBeNull(); user.Id.Should().Be(TestIds.UserId2); @@ -77,7 +77,7 @@ public async Task ReturnsNullFromNonExisting() var context = new MongoTestContext(GetConnection()); var store = new MongoUserStore(context); - var user = await store.FindByLoginAsync("provider5", "provider-key"); + var user = await store.FindByLoginAsync("provider5", "provider-key", TestContext.Current.CancellationToken); user.Should().BeNull(); } @@ -88,7 +88,7 @@ public async Task ReturnsNullFromNull() var context = new MongoTestContext(GetConnection()); var store = new MongoUserStore(context); - var user = await store.FindByLoginAsync(null, "provider-key"); + var user = await store.FindByLoginAsync(null, "provider-key", TestContext.Current.CancellationToken); user.Should().BeNull(); } diff --git a/tests/MongoFramework.AspNetCore.Identity.Tests/MongoUserStoreTests/FindByName.cs b/tests/MongoFramework.AspNetCore.Identity.Tests/MongoUserStoreTests/FindByName.cs index d7747c2..d7138f6 100644 --- a/tests/MongoFramework.AspNetCore.Identity.Tests/MongoUserStoreTests/FindByName.cs +++ b/tests/MongoFramework.AspNetCore.Identity.Tests/MongoUserStoreTests/FindByName.cs @@ -13,7 +13,7 @@ public class FindByName : TestBase, IAsyncLifetime public FindByName() : base("MongoUserStore-FindByName") { } - public async Task InitializeAsync() + public async ValueTask InitializeAsync() { var context = new MongoTestContext(GetConnection()); var store = new MongoUserStore(context); @@ -23,7 +23,7 @@ public async Task InitializeAsync() await store.CreateAsync(MongoTestUser.Third); } - public Task DisposeAsync() => Task.CompletedTask; + public ValueTask DisposeAsync() => ValueTask.CompletedTask; [Fact] public async Task FindsCorrectUserWithValidUserName() @@ -31,7 +31,7 @@ public async Task FindsCorrectUserWithValidUserName() var context = new MongoTestContext(GetConnection()); var store = new MongoUserStore(context); - var result = await store.FindByNameAsync("USER NAME2"); + var result = await store.FindByNameAsync("USER NAME2", TestContext.Current.CancellationToken); result.Should().NotBeNull(); result.UserName.Should().Be("User Name2"); @@ -43,10 +43,10 @@ public async Task FindsTrackedEntityWithValidUserName() { var context = new MongoTestContext(GetConnection()); var store = new MongoUserStore(context); - var tracked = await store.FindByIdAsync(TestIds.UserId2); + var tracked = await store.FindByIdAsync(TestIds.UserId2, TestContext.Current.CancellationToken); tracked.CustomData = "updated"; - var result = await store.FindByNameAsync("USER NAME2"); + var result = await store.FindByNameAsync("USER NAME2", TestContext.Current.CancellationToken); result.Should().BeSameAs(tracked); result.CustomData.Should().Be("updated"); @@ -59,7 +59,7 @@ public async Task ReturnsNullWithInvalidUserName() var context = new MongoTestContext(GetConnection()); var store = new MongoUserStore(context); - var result = await store.FindByNameAsync("none"); + var result = await store.FindByNameAsync("none", TestContext.Current.CancellationToken); result.Should().BeNull(); } diff --git a/tests/MongoFramework.AspNetCore.Identity.Tests/MongoUserStoreTests/FindUserRole.cs b/tests/MongoFramework.AspNetCore.Identity.Tests/MongoUserStoreTests/FindUserRole.cs index d975ac3..c53a6e5 100644 --- a/tests/MongoFramework.AspNetCore.Identity.Tests/MongoUserStoreTests/FindUserRole.cs +++ b/tests/MongoFramework.AspNetCore.Identity.Tests/MongoUserStoreTests/FindUserRole.cs @@ -25,7 +25,7 @@ public async Task> ExposeFindUserRoleAsync(string userI public FindUserRole() : base("MongoUserStore-FindUserRole") { } - public async Task InitializeAsync() + public async ValueTask InitializeAsync() { var context = new MongoTestContext(GetConnection()); var store = new MongoUserStore(context); @@ -43,7 +43,7 @@ public async Task InitializeAsync() } - public Task DisposeAsync() => Task.CompletedTask; + public ValueTask DisposeAsync() => ValueTask.CompletedTask; [Fact] public async Task FindUserRoleWithValidRole() diff --git a/tests/MongoFramework.AspNetCore.Identity.Tests/MongoUserStoreTests/GetRoles.cs b/tests/MongoFramework.AspNetCore.Identity.Tests/MongoUserStoreTests/GetRoles.cs index 1d83c67..b51c005 100644 --- a/tests/MongoFramework.AspNetCore.Identity.Tests/MongoUserStoreTests/GetRoles.cs +++ b/tests/MongoFramework.AspNetCore.Identity.Tests/MongoUserStoreTests/GetRoles.cs @@ -14,7 +14,7 @@ public class GetRoles : TestBase, IAsyncLifetime public GetRoles() : base("MongoUserStore-GetRoles") { } - public async Task InitializeAsync() + public async ValueTask InitializeAsync() { var context = new MongoTestContext(GetConnection()); var store = new MongoUserStore(context); @@ -32,16 +32,16 @@ public async Task InitializeAsync() } - public Task DisposeAsync() => Task.CompletedTask; + public ValueTask DisposeAsync() => ValueTask.CompletedTask; [Fact] public async Task GetRolesWithUser() { var context = new MongoTestContext(GetConnection()); var store = new MongoUserStore(context); - var user = await store.FindByIdAsync(TestIds.UserId1); + var user = await store.FindByIdAsync(TestIds.UserId1, TestContext.Current.CancellationToken); - var roles = await store.GetRolesAsync(user); + var roles = await store.GetRolesAsync(user, TestContext.Current.CancellationToken); roles.Count.Should().Be(2); roles[0].Should().Be("Role 1"); diff --git a/tests/MongoFramework.AspNetCore.Identity.Tests/MongoUserStoreTests/IdentitySpecTests.cs b/tests/MongoFramework.AspNetCore.Identity.Tests/MongoUserStoreTests/IdentitySpecTests.cs index b4a7405..605df36 100644 --- a/tests/MongoFramework.AspNetCore.Identity.Tests/MongoUserStoreTests/IdentitySpecTests.cs +++ b/tests/MongoFramework.AspNetCore.Identity.Tests/MongoUserStoreTests/IdentitySpecTests.cs @@ -84,32 +84,32 @@ public async Task SqlUserStoreMethodsThrowWhenDisposedTest() { var store = new MongoUserStore(CreateContext()); store.Dispose(); - await Assert.ThrowsAsync(async () => await store.AddClaimsAsync(null, null)); - await Assert.ThrowsAsync(async () => await store.AddLoginAsync(null, null)); - await Assert.ThrowsAsync(async () => await store.AddToRoleAsync(null, null)); - await Assert.ThrowsAsync(async () => await store.GetClaimsAsync(null)); - await Assert.ThrowsAsync(async () => await store.GetLoginsAsync(null)); - await Assert.ThrowsAsync(async () => await store.GetRolesAsync(null)); - await Assert.ThrowsAsync(async () => await store.IsInRoleAsync(null, null)); - await Assert.ThrowsAsync(async () => await store.RemoveClaimsAsync(null, null)); - await Assert.ThrowsAsync(async () => await store.RemoveLoginAsync(null, null, null)); + await Assert.ThrowsAsync(async () => await store.AddClaimsAsync(null, null, TestContext.Current.CancellationToken)); + await Assert.ThrowsAsync(async () => await store.AddLoginAsync(null, null, TestContext.Current.CancellationToken)); + await Assert.ThrowsAsync(async () => await store.AddToRoleAsync(null, null, TestContext.Current.CancellationToken)); + await Assert.ThrowsAsync(async () => await store.GetClaimsAsync(null, TestContext.Current.CancellationToken)); + await Assert.ThrowsAsync(async () => await store.GetLoginsAsync(null, TestContext.Current.CancellationToken)); + await Assert.ThrowsAsync(async () => await store.GetRolesAsync(null, TestContext.Current.CancellationToken)); + await Assert.ThrowsAsync(async () => await store.IsInRoleAsync(null, null, TestContext.Current.CancellationToken)); + await Assert.ThrowsAsync(async () => await store.RemoveClaimsAsync(null, null, TestContext.Current.CancellationToken)); + await Assert.ThrowsAsync(async () => await store.RemoveLoginAsync(null, null, null, TestContext.Current.CancellationToken)); await Assert.ThrowsAsync( - async () => await store.RemoveFromRoleAsync(null, null)); - await Assert.ThrowsAsync(async () => await store.RemoveClaimsAsync(null, null)); - await Assert.ThrowsAsync(async () => await store.ReplaceClaimAsync(null, null, null)); - await Assert.ThrowsAsync(async () => await store.FindByLoginAsync(null, null)); - await Assert.ThrowsAsync(async () => await store.FindByIdAsync(null)); - await Assert.ThrowsAsync(async () => await store.FindByNameAsync(null)); - await Assert.ThrowsAsync(async () => await store.CreateAsync(null)); - await Assert.ThrowsAsync(async () => await store.UpdateAsync(null)); - await Assert.ThrowsAsync(async () => await store.DeleteAsync(null)); + async () => await store.RemoveFromRoleAsync(null, null, TestContext.Current.CancellationToken)); + await Assert.ThrowsAsync(async () => await store.RemoveClaimsAsync(null, null, TestContext.Current.CancellationToken)); + await Assert.ThrowsAsync(async () => await store.ReplaceClaimAsync(null, null, null, TestContext.Current.CancellationToken)); + await Assert.ThrowsAsync(async () => await store.FindByLoginAsync(null, null, TestContext.Current.CancellationToken)); + await Assert.ThrowsAsync(async () => await store.FindByIdAsync(null, TestContext.Current.CancellationToken)); + await Assert.ThrowsAsync(async () => await store.FindByNameAsync(null, TestContext.Current.CancellationToken)); + await Assert.ThrowsAsync(async () => await store.CreateAsync(null, TestContext.Current.CancellationToken)); + await Assert.ThrowsAsync(async () => await store.UpdateAsync(null, TestContext.Current.CancellationToken)); + await Assert.ThrowsAsync(async () => await store.DeleteAsync(null, TestContext.Current.CancellationToken)); await Assert.ThrowsAsync( - async () => await store.SetEmailConfirmedAsync(null, true)); - await Assert.ThrowsAsync(async () => await store.GetEmailConfirmedAsync(null)); + async () => await store.SetEmailConfirmedAsync(null, true, TestContext.Current.CancellationToken)); + await Assert.ThrowsAsync(async () => await store.GetEmailConfirmedAsync(null, TestContext.Current.CancellationToken)); await Assert.ThrowsAsync( - async () => await store.SetPhoneNumberConfirmedAsync(null, true)); + async () => await store.SetPhoneNumberConfirmedAsync(null, true, TestContext.Current.CancellationToken)); await Assert.ThrowsAsync( - async () => await store.GetPhoneNumberConfirmedAsync(null)); + async () => await store.GetPhoneNumberConfirmedAsync(null, TestContext.Current.CancellationToken)); } [Fact]