Skip to content

Commit eae1055

Browse files
committed
rename test classes to avoid conflict with xunit
1 parent 024bac0 commit eae1055

34 files changed

+308
-301
lines changed

Net9MultiTenant/Models/ToDoItem.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
{
33
public class ToDoItem
44
{
5-
public string Id { get; set; }
6-
public string Title { get; set; }
7-
public bool Completed { get; set; }
5+
public string? Id { get; set; }
6+
public string? Title { get; set; }
7+
public bool? Completed { get; set; }
88
}
99
}

Net9MultiTenant/Pages/Index.cshtml

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -69,16 +69,21 @@ else
6969
</thead>
7070

7171
<tbody>
72-
@foreach (var item in Model.ToDoItems)
73-
{
74-
<tr>
75-
<td>@item.Title</td>
76-
<td style="width: 2rem"><input asp-for="@item.Completed" /></td>
77-
<td style="width: 4rem" class="text-muted">@item.Id</td>
78-
@* <td style="width: 4rem" class="text-muted">@item.TenantId</td> *@
79-
</tr>
80-
}
81-
</tbody>
72+
@if (Model.ToDoItems != null)
73+
{
74+
foreach (var item in Model.ToDoItems)
75+
{
76+
<tr>
77+
<td>@item.Title</td>
78+
<td style="width: 2rem">
79+
<input asp-for="@ModelExpressionProvider.CreateModelExpression(ViewData, __model => item.Completed)"/>
80+
</td>
81+
<td style="width: 4rem" class="text-muted">@item.Id</td>
82+
@* <td style="width: 4rem" class="text-muted">@item.TenantId</td> *@
83+
</tr>
84+
}
85+
}
86+
</tbody>
8287
</table>
8388
<table class="table">
8489
<thead>

Net9MultiTenant/Pages/Index.cshtml.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
namespace Net9MultiTenant.Pages
88
{
9-
public class IndexModel(ILogger<IndexModel> logger, ApplicationDbContext dbContext) : PageModel
9+
public class IndexModel(ApplicationDbContext dbContext) : PageModel
1010
{
1111
public TenantInfo? TenantInfo { get; private set; }
1212
public IEnumerable<ToDoItem>? ToDoItems { get; private set; } = new List<ToDoItem>();

Net9MultiTenant/Pages/NoTenant.cshtml.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
namespace Net9MultiTenant.Pages
99
{
1010
[ExcludeFromMultiTenantResolution]
11-
public class NoTenantModel(ILogger<IndexModel> logger) : PageModel
11+
public class NoTenantModel() : PageModel
1212
{
1313
[ExcludeFromMultiTenantResolution]
1414
public async Task OnGet()

Net9MultiTenant/Pages/Shared/_Layout.cshtml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
@using Finbuckle.MultiTenant
2-
@using Finbuckle.MultiTenant
1+
@using Finbuckle.MultiTenant
32
@using Finbuckle.MultiTenant.Abstractions
43
@using Microsoft.AspNetCore.Mvc.TagHelpers
54
@inject IMultiTenantStore<TenantInfo> _tenantStore

Net9MultiTenant/SeedService.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,8 @@ private static async Task SetupStore(IMultiTenantStore<TenantInfo> store)
3636
private static async Task SetupDb(ApplicationDbContext context, IMultiTenantStore<TenantInfo> store, IConfiguration config, IServiceProvider serviceProvider)
3737
{
3838
var ti = await store.TryGetByIdentifierAsync("acme");
39-
39+
if (ti == null) return;
40+
4041
using var db1 = MultiTenantDbContext.Create<ApplicationDbContext, TenantInfo>(ti, serviceProvider);
4142

4243
if (!db1.ToDoItems.Any())
@@ -48,6 +49,7 @@ private static async Task SetupDb(ApplicationDbContext context, IMultiTenantStor
4849
}
4950

5051
ti = store.TryGetByIdentifierAsync("megacorp").Result;
52+
if (ti == null) return;
5153
using var db2 = MultiTenantDbContext.Create<ApplicationDbContext, TenantInfo>(ti, serviceProvider);
5254
if (!db2.ToDoItems.Any())
5355
{
@@ -58,6 +60,7 @@ private static async Task SetupDb(ApplicationDbContext context, IMultiTenantStor
5860
}
5961

6062
ti = store.TryGetByIdentifierAsync("initech").Result;
63+
if (ti == null) return;
6164
using var db3 = MultiTenantDbContext.Create<ApplicationDbContext, TenantInfo>(ti, serviceProvider);
6265
if (!db3.ToDoItems.Any())
6366
{

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ public async Task InitializeAsync()
3333

3434
await context.SaveChangesAsync();
3535

36-
var user = TestUser.First;
36+
var user = MongoTestUser.First;
3737
user.Roles.Add(TestIds.RoleId1);
3838
user.Roles.Add(TestIds.RoleId2);
3939
await store.CreateAsync(user);

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

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,16 +14,16 @@ public MongoRoleStoreTests() : base("MongoRoleStore") { }
1414

1515
public async Task InitializeAsync()
1616
{
17-
var context = new TestContext(GetConnection());
18-
var store = new MongoUserStore<TestUser>(context);
17+
var context = new MongoTestContext(GetConnection());
18+
var store = new MongoUserStore<MongoTestUser>(context);
1919

2020
context.Roles.Add(new MongoIdentityRole { Id = "rid1", Name = "Role 1" });
2121
context.Roles.Add(new MongoIdentityRole { Id = "rid2", Name = "Role 2" });
2222
context.Roles.Add(new MongoIdentityRole { Id = "rid3", Name = "Role 3" });
2323

2424
await context.SaveChangesAsync();
2525

26-
var user = TestUser.First;
26+
var user = MongoTestUser.First;
2727
user.Roles.Add("rid1");
2828
user.Roles.Add("rid2");
2929
await store.CreateAsync(user);
@@ -35,17 +35,17 @@ public async Task InitializeAsync()
3535
[Fact]
3636
public void ConstructorUsesMongo()
3737
{
38-
var context = new TestContext(GetConnection());
38+
var context = new MongoTestContext(GetConnection());
3939

4040
var store = new MongoRoleStore<MongoIdentityRole>(context);
4141

42-
store.Context.Should().BeOfType<TestContext>();
42+
store.Context.Should().BeOfType<MongoTestContext>();
4343
}
4444

4545
[Fact]
4646
public void ConvertIdFromStringWithIntReturnsZero()
4747
{
48-
var context = new TestContext(GetConnection());
48+
var context = new MongoTestContext(GetConnection());
4949

5050
var store = new MongoRoleStore<MongoIdentityRole<int>, DbContext, int>(context);
5151

@@ -56,7 +56,7 @@ public void ConvertIdFromStringWithIntReturnsZero()
5656
[Fact]
5757
public void ConvertIdToStringWithIntReturnsNull()
5858
{
59-
var context = new TestContext(GetConnection());
59+
var context = new MongoTestContext(GetConnection());
6060

6161
var store = new MongoRoleStore<MongoIdentityRole<int>, DbContext, int>(context);
6262

@@ -67,7 +67,7 @@ public void ConvertIdToStringWithIntReturnsNull()
6767
[Fact]
6868
public async Task GetNormalizedRoleReturnsCorrect()
6969
{
70-
var context = new TestContext(GetConnection());
70+
var context = new MongoTestContext(GetConnection());
7171
var store = new MongoRoleStore<MongoIdentityRole<int>, DbContext, int>(context);
7272

7373
var role = new MongoIdentityRole<int> { Name = "testrole", NormalizedName = "TESTROLE" };

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

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -16,19 +16,19 @@ public AddClaims() : base("MongoUserOnlyStore-AddClaims") { }
1616

1717
public async Task InitializeAsync()
1818
{
19-
var context = new TestContext(GetConnection());
20-
var store = new MongoUserOnlyStore<TestUser>(context);
19+
var context = new MongoTestContext(GetConnection());
20+
var store = new MongoUserOnlyStore<MongoTestUser>(context);
2121

22-
await store.CreateAsync(TestUser.First);
22+
await store.CreateAsync(MongoTestUser.First);
2323
}
2424

2525
public Task DisposeAsync() => Task.CompletedTask;
2626

2727
[Fact]
2828
public async Task UpdatesUser()
2929
{
30-
var context = new TestContext(GetConnection());
31-
var store = new MongoUserOnlyStore<TestUser>(context);
30+
var context = new MongoTestContext(GetConnection());
31+
var store = new MongoUserOnlyStore<MongoTestUser>(context);
3232
var user = await store.FindByIdAsync(TestIds.UserId1);
3333

3434
await store.AddClaimsAsync(user,
@@ -45,8 +45,8 @@ await store.AddClaimsAsync(user,
4545
[Fact]
4646
public async Task SavesData()
4747
{
48-
var context = new TestContext(GetConnection());
49-
var store = new MongoUserOnlyStore<TestUser>(context);
48+
var context = new MongoTestContext(GetConnection());
49+
var store = new MongoUserOnlyStore<MongoTestUser>(context);
5050
var user = await store.FindByIdAsync(TestIds.UserId1);
5151

5252
await store.AddClaimsAsync(user,
@@ -58,8 +58,8 @@ await store.AddClaimsAsync(user,
5858

5959
await store.UpdateAsync(user);
6060

61-
context = new TestContext(GetConnection());
62-
store = new MongoUserOnlyStore<TestUser>(context);
61+
context = new MongoTestContext(GetConnection());
62+
store = new MongoUserOnlyStore<MongoTestUser>(context);
6363
user = await store.FindByIdAsync(TestIds.UserId1);
6464

6565
user.Claims.Count.Should().Be(2);
@@ -69,9 +69,9 @@ await store.AddClaimsAsync(user,
6969
[Fact]
7070
public async Task ThrowsExceptionWithNullArguments()
7171
{
72-
var context = new TestContext(GetConnection());
73-
var store = new MongoUserOnlyStore<TestUser>(context);
74-
var user = new TestUser();
72+
var context = new MongoTestContext(GetConnection());
73+
var store = new MongoUserOnlyStore<MongoTestUser>(context);
74+
var user = new MongoTestUser();
7575

7676
var act = async () =>
7777
{

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

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -16,21 +16,21 @@ public AddLogin() : base("MongoUserOnlyStore-AddLogin") { }
1616

1717
public async Task InitializeAsync()
1818
{
19-
var context = new TestContext(GetConnection());
20-
var store = new MongoUserOnlyStore<TestUser>(context);
19+
var context = new MongoTestContext(GetConnection());
20+
var store = new MongoUserOnlyStore<MongoTestUser>(context);
2121

22-
await store.CreateAsync(TestUser.First);
23-
await store.CreateAsync(TestUser.Second);
24-
await store.CreateAsync(TestUser.Third);
22+
await store.CreateAsync(MongoTestUser.First);
23+
await store.CreateAsync(MongoTestUser.Second);
24+
await store.CreateAsync(MongoTestUser.Third);
2525
}
2626

2727
public Task DisposeAsync() => Task.CompletedTask;
2828

2929
[Fact]
3030
public async Task UpdatesUser()
3131
{
32-
var context = new TestContext(GetConnection());
33-
var store = new MongoUserOnlyStore<TestUser>(context);
32+
var context = new MongoTestContext(GetConnection());
33+
var store = new MongoUserOnlyStore<MongoTestUser>(context);
3434
var user = await store.FindByIdAsync(TestIds.UserId1);
3535

3636
await store.AddLoginAsync(user, new UserLoginInfo("provider1", "provider-key", "Login Provider"));
@@ -42,15 +42,15 @@ public async Task UpdatesUser()
4242
[Fact]
4343
public async Task SavesData()
4444
{
45-
var context = new TestContext(GetConnection());
46-
var store = new MongoUserOnlyStore<TestUser>(context);
45+
var context = new MongoTestContext(GetConnection());
46+
var store = new MongoUserOnlyStore<MongoTestUser>(context);
4747
var user = await store.FindByIdAsync(TestIds.UserId1);
4848

4949
await store.AddLoginAsync(user, new UserLoginInfo("provider1", "provider-key", "Login Provider"));
5050
await store.UpdateAsync(user);
5151

52-
context = new TestContext(GetConnection());
53-
store = new MongoUserOnlyStore<TestUser>(context);
52+
context = new MongoTestContext(GetConnection());
53+
store = new MongoUserOnlyStore<MongoTestUser>(context);
5454
user = await store.FindByIdAsync(TestIds.UserId1);
5555

5656
user.Logins.Count.Should().Be(1);
@@ -60,9 +60,9 @@ public async Task SavesData()
6060
[Fact]
6161
public async Task ThrowsExceptionWithNullArguments()
6262
{
63-
var context = new TestContext(GetConnection());
64-
var store = new MongoUserOnlyStore<TestUser>(context);
65-
var user = new TestUser();
63+
var context = new MongoTestContext(GetConnection());
64+
var store = new MongoUserOnlyStore<MongoTestUser>(context);
65+
var user = new MongoTestUser();
6666

6767
var act = async () =>
6868
{

0 commit comments

Comments
 (0)