-
Notifications
You must be signed in to change notification settings - Fork 337
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'refs/remotes/origin/dev'
- Loading branch information
Showing
24 changed files
with
244 additions
and
64 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
namespace Abp.MultiTenancy | ||
{ | ||
public class TenantStore : ITenantStore | ||
{ | ||
private readonly ITenantCache _tenantCache; | ||
|
||
public TenantStore(ITenantCache tenantCache) | ||
{ | ||
_tenantCache = tenantCache; | ||
} | ||
|
||
public TenantInfo Find(int tenantId) | ||
{ | ||
var tenant = _tenantCache.GetOrNull(tenantId); | ||
if (tenant == null) | ||
{ | ||
return null; | ||
} | ||
|
||
return new TenantInfo(tenant.Id, tenant.TenancyName); | ||
} | ||
|
||
public TenantInfo Find(string tenancyName) | ||
{ | ||
var tenant = _tenantCache.GetOrNull(tenancyName); | ||
if (tenant == null) | ||
{ | ||
return null; | ||
} | ||
|
||
return new TenantInfo(tenant.Id, tenant.TenancyName); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
46 changes: 46 additions & 0 deletions
46
test/Abp.Zero.SampleApp.Tests/MultiTenancy/TenantStore_Tests.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
using Abp.MultiTenancy; | ||
using Abp.Zero.SampleApp.MultiTenancy; | ||
using Shouldly; | ||
using Xunit; | ||
|
||
namespace Abp.Zero.SampleApp.Tests.MultiTenancy | ||
{ | ||
public class TenantStore_Tests : SampleAppTestBase | ||
{ | ||
private readonly ITenantStore _tenantStore; | ||
|
||
public TenantStore_Tests() | ||
{ | ||
_tenantStore = Resolve<ITenantStore>(); | ||
} | ||
|
||
|
||
[Fact] | ||
public void Should_Get_Tenant_By_Id() | ||
{ | ||
//Act | ||
var tenant = _tenantStore.Find(1); | ||
|
||
//Assert | ||
Assert.NotNull(tenant); | ||
tenant.TenancyName.ShouldBe(Tenant.DefaultTenantName); | ||
} | ||
|
||
[Fact] | ||
public void Should_Get_Tenant_By_Name() | ||
{ | ||
//Act | ||
var tenant = _tenantStore.Find(Tenant.DefaultTenantName); | ||
|
||
//Assert | ||
Assert.NotNull(tenant); | ||
tenant.Id.ShouldBe(1); | ||
} | ||
|
||
[Fact] | ||
public void Should_Not_Get_Unknown_Tenant() | ||
{ | ||
Assert.Null(_tenantStore.Find("unknown-tenancy-name")); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -27,12 +27,23 @@ private void CreateUsers() | |
var admin = _context.Users.Add( | ||
new User | ||
{ | ||
TenantId = defaultTenant.Id, | ||
Name = "System", | ||
Surname = "Administrator", | ||
UserName = User.AdminUserName, | ||
Password = new PasswordHasher().HashPassword("123qwe"), | ||
EmailAddress = "[email protected]" | ||
TenantId = defaultTenant.Id, | ||
Name = "System", | ||
Surname = "Administrator", | ||
UserName = User.AdminUserName, | ||
Password = new PasswordHasher().HashPassword("123qwe"), | ||
EmailAddress = "[email protected]" | ||
}); | ||
|
||
_context.Users.Add( | ||
new User | ||
{ | ||
TenantId = defaultTenant.Id, | ||
Name = "System", | ||
Surname = "Manager", | ||
UserName = "manager", | ||
Password = new PasswordHasher().HashPassword("123qwe"), | ||
EmailAddress = "[email protected]" | ||
}); | ||
} | ||
} | ||
|
Oops, something went wrong.