Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/dotnet-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ on:
branches: [main]
pull_request:
branches: [main]
workflow_dispatch:

jobs:
build:
Expand Down
2 changes: 1 addition & 1 deletion Net9MultiTenant/Pages/NoTenant.cshtml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ namespace Net9MultiTenant.Pages
public class NoTenantModel() : PageModel
{
[ExcludeFromMultiTenantResolution]
public async Task OnGet()
public void OnGet()
{

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,11 @@
<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="18.0.0" />
<PackageReference Include="AwesomeAssertions" Version="9.2.1" />
<PackageReference Include="xunit" Version="2.9.3" />
<PackageReference Include="xunit.v3" Version="3.1.0" />
<PackageReference Include="xunit.runner.visualstudio" Version="3.1.5">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="coverlet.collector" Version="6.0.4">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<MongoIdentityUser>(context);
Expand All @@ -40,7 +40,7 @@ public async Task InitializeAsync()

}

public Task DisposeAsync() => Task.CompletedTask;
public ValueTask DisposeAsync() => ValueTask.CompletedTask;

[Fact]
public void ContextWithRolesLoadsRoles()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<MongoTestUser>(context);
Expand All @@ -30,7 +30,7 @@ public async Task InitializeAsync()

}

public Task DisposeAsync() => Task.CompletedTask;
public ValueTask DisposeAsync() => ValueTask.CompletedTask;

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

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

name.Should().Be("TESTROLE");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,29 +14,29 @@ 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<MongoTestUser>(context);

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<MongoTestUser>(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");
Expand All @@ -47,20 +47,20 @@ public async Task SavesData()
{
var context = new MongoTestContext(GetConnection());
var store = new MongoUserOnlyStore<MongoTestUser>(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<MongoTestUser>(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");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<MongoTestUser>(context);
Expand All @@ -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<MongoTestUser>(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");
Expand All @@ -44,14 +44,14 @@ public async Task SavesData()
{
var context = new MongoTestContext(GetConnection());
var store = new MongoUserOnlyStore<MongoTestUser>(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<MongoTestUser>(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");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public async Task ReturnsSuccessWithStringId()
var context = new MongoTestContext(GetConnection());
var store = new MongoUserOnlyStore<MongoTestUser>(context);

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

result.Should().Be(IdentityResult.Success);
}
Expand All @@ -31,7 +31,7 @@ public async Task CreatesDataWithStringId()
var context = new MongoTestContext(GetConnection());
var store = new MongoUserOnlyStore<MongoTestUser>(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);
Expand All @@ -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);
Expand All @@ -59,7 +59,7 @@ public async Task ReturnsSuccessWithIntId()
var context = new MongoTestContext(GetConnection());
var store = new MongoUserOnlyStore<MongoTestUserInt, DbContext, int>(context);

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

result.Should().Be(IdentityResult.Success);
}
Expand All @@ -70,7 +70,7 @@ public async Task CreatesDataWithIntId()
var context = new MongoTestContext(GetConnection());
var store = new MongoUserOnlyStore<MongoTestUserInt, DbContext, int>(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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,15 @@ public async Task DeletesDataWithValidUser()
{
var context = new MongoTestContext(GetConnection());
var store = new MongoUserOnlyStore<MongoTestUser>(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<MongoTestUser>(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();
}
Expand All @@ -37,15 +37,15 @@ public async Task ReturnsSuccessWithValidUser()
{
var context = new MongoTestContext(GetConnection());
var store = new MongoUserOnlyStore<MongoTestUser>(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<MongoTestUser>(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);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<MongoTestUser>(context);
Expand All @@ -23,15 +23,15 @@ public async Task InitializeAsync()
await store.CreateAsync(MongoTestUser.Third);
}

public Task DisposeAsync() => Task.CompletedTask;
public ValueTask DisposeAsync() => ValueTask.CompletedTask;

[Fact]
public async Task FindsCorrectUserWithValidEmail()
{
var context = new MongoTestContext(GetConnection());
var store = new MongoUserOnlyStore<MongoTestUser>(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");
Expand All @@ -42,10 +42,10 @@ public async Task FindsTrackedEntityWithValidEmail()
{
var context = new MongoTestContext(GetConnection());
var store = new MongoUserOnlyStore<MongoTestUser>(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");
Expand All @@ -57,7 +57,7 @@ public async Task ReturnsNullWithInvalidEmail()
var context = new MongoTestContext(GetConnection());
var store = new MongoUserOnlyStore<MongoTestUser>(context);

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

result.Should().BeNull();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<MongoTestUser>(context);
Expand All @@ -28,15 +28,15 @@ public async Task InitializeAsync()
await store2.CreateAsync(MongoTestUserInt.Third);
}

public Task DisposeAsync() => Task.CompletedTask;
public ValueTask DisposeAsync() => ValueTask.CompletedTask;

[Fact]
public async Task FindsCorrectUserWithValidStringId()
{
var context = new MongoTestContext(GetConnection());
var store = new MongoUserOnlyStore<MongoTestUser>(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");
Expand All @@ -48,7 +48,7 @@ public async Task ReturnsNullWithInvalidStringId()
var context = new MongoTestContext(GetConnection());
var store = new MongoUserOnlyStore<MongoTestUser>(context);

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

result.Should().BeNull();
}
Expand All @@ -59,7 +59,7 @@ public async Task FindsCorrectUserWithValidIntId()
var context = new MongoTestContext(GetConnection());
var store = new MongoUserOnlyStore<MongoTestUserInt, DbContext, int>(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");
Expand All @@ -71,7 +71,7 @@ public async Task ReturnsNullWithInvalidIntId()
var context = new MongoTestContext(GetConnection());
var store = new MongoUserOnlyStore<MongoTestUserInt, DbContext, int>(context);

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

result.Should().BeNull();
}
Expand Down
Loading
Loading