mirror of https://github.com/abpframework/abp.git
9 changed files with 209 additions and 2 deletions
@ -0,0 +1,18 @@ |
|||
<Project Sdk="Microsoft.NET.Sdk"> |
|||
|
|||
<PropertyGroup> |
|||
<TargetFramework>netcoreapp2.2</TargetFramework> |
|||
|
|||
<IsPackable>false</IsPackable> |
|||
</PropertyGroup> |
|||
|
|||
<ItemGroup> |
|||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.9.0" /> |
|||
</ItemGroup> |
|||
|
|||
<ItemGroup> |
|||
<ProjectReference Include="..\Volo.Abp.TenantManagement.EntityFrameworkCore.Tests\Volo.Abp.TenantManagement.EntityFrameworkCore.Tests.csproj" /> |
|||
<ProjectReference Include="..\Volo.Abp.TenantManagement.TestBase\Volo.Abp.TenantManagement.TestBase.csproj" /> |
|||
</ItemGroup> |
|||
|
|||
</Project> |
|||
@ -0,0 +1,11 @@ |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.Text; |
|||
|
|||
namespace Volo.Abp.TenantManagement |
|||
{ |
|||
public class AbpTenantManagementDomainTestBase : TenantManagementTestBase<AbpSettingManagementDomainTestModule> |
|||
{ |
|||
|
|||
} |
|||
} |
|||
@ -0,0 +1,15 @@ |
|||
using System; |
|||
using Volo.Abp.Modularity; |
|||
using Volo.Abp.TenantManagement.EntityFrameworkCore; |
|||
using Xunit; |
|||
|
|||
namespace Volo.Abp.TenantManagement |
|||
{ |
|||
[DependsOn( |
|||
typeof(AbpTenantManagementEntityFrameworkCoreTestModule), |
|||
typeof(AbpTenantManagementTestBaseModule))] |
|||
public class AbpSettingManagementDomainTestModule : AbpModule |
|||
{ |
|||
|
|||
} |
|||
} |
|||
@ -0,0 +1,23 @@ |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.Text; |
|||
using System.Threading.Tasks; |
|||
using Shouldly; |
|||
using Xunit; |
|||
|
|||
namespace Volo.Abp.TenantManagement |
|||
{ |
|||
public class TenantConnectionString_Tests |
|||
{ |
|||
[Theory] |
|||
[InlineData("aaa")] |
|||
[InlineData("bbb")] |
|||
public async Task SetValue(string value) |
|||
{ |
|||
var tenantConnectionString = |
|||
new TenantConnectionString(Guid.NewGuid(), "MyConnString", "MyConnString-Value"); |
|||
tenantConnectionString.SetValue(value); |
|||
tenantConnectionString.Value.ShouldBe(value); |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,55 @@ |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.Text; |
|||
using System.Threading.Tasks; |
|||
using Shouldly; |
|||
using Xunit; |
|||
|
|||
namespace Volo.Abp.TenantManagement |
|||
{ |
|||
public class TenantManager_Tests : AbpTenantManagementDomainTestBase |
|||
{ |
|||
private readonly ITenantManager _tenantManager; |
|||
private readonly ITenantRepository _tenantRepository; |
|||
|
|||
public TenantManager_Tests() |
|||
{ |
|||
_tenantManager = GetRequiredService<ITenantManager>(); |
|||
_tenantRepository = GetRequiredService<ITenantRepository>(); |
|||
} |
|||
|
|||
|
|||
[Fact] |
|||
public async Task CreateAsync() |
|||
{ |
|||
var tenant = await _tenantManager.CreateAsync("Test"); |
|||
tenant.Name.ShouldBe("Test"); |
|||
} |
|||
|
|||
[Fact] |
|||
public async Task Create_Tenant_Name_Can_Not_Duplicate() |
|||
{ |
|||
await Assert.ThrowsAsync<UserFriendlyException>(async () => await _tenantManager.CreateAsync("volosoft")); |
|||
} |
|||
|
|||
[Fact] |
|||
public async Task ChangeNameAsync() |
|||
{ |
|||
var tenant = await _tenantRepository.FindByNameAsync("volosoft"); |
|||
tenant.ShouldNotBeNull(); |
|||
|
|||
await _tenantManager.ChangeNameAsync(tenant, "newVolosoft"); |
|||
|
|||
tenant.Name.ShouldBe("newVolosoft"); |
|||
} |
|||
|
|||
[Fact] |
|||
public async Task ChangeName_Tenant_Name_Can_Not_Duplicate() |
|||
{ |
|||
var tenant = await _tenantRepository.FindByNameAsync("acme"); |
|||
tenant.ShouldNotBeNull(); |
|||
|
|||
await Assert.ThrowsAsync<UserFriendlyException>(async () => await _tenantManager.ChangeNameAsync(tenant, "volosoft")); |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,39 @@ |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.Text; |
|||
using System.Threading.Tasks; |
|||
using Shouldly; |
|||
using Volo.Abp.MultiTenancy; |
|||
using Xunit; |
|||
|
|||
namespace Volo.Abp.TenantManagement |
|||
{ |
|||
public class TenantStore_Tests : AbpTenantManagementDomainTestBase |
|||
{ |
|||
private readonly ITenantStore _tenantStore; |
|||
private readonly ITenantRepository _tenantRepository; |
|||
|
|||
public TenantStore_Tests() |
|||
{ |
|||
_tenantStore = GetRequiredService<ITenantStore>(); |
|||
_tenantRepository = GetRequiredService<ITenantRepository>(); |
|||
} |
|||
|
|||
[Fact] |
|||
public async Task FindAsyncByName() |
|||
{ |
|||
var acme = await _tenantStore.FindAsync("acme"); |
|||
acme.ShouldNotBeNull(); |
|||
acme.Name.ShouldBe("acme"); |
|||
} |
|||
|
|||
[Fact] |
|||
public async Task FindAsyncById() |
|||
{ |
|||
var acme = await _tenantRepository.FindByNameAsync("acme"); |
|||
acme.ShouldNotBeNull(); |
|||
|
|||
(await _tenantStore.FindAsync(acme.Id)).ShouldNotBeNull(); |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,38 @@ |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.Text; |
|||
using System.Threading.Tasks; |
|||
using Shouldly; |
|||
using Xunit; |
|||
|
|||
namespace Volo.Abp.TenantManagement |
|||
{ |
|||
public class Tenant_Tests : AbpTenantManagementDomainTestBase |
|||
{ |
|||
private readonly ITenantRepository _tenantRepository; |
|||
|
|||
public Tenant_Tests() |
|||
{ |
|||
_tenantRepository = GetRequiredService<ITenantRepository>(); |
|||
} |
|||
|
|||
[Fact] |
|||
public async Task FindDefaultConnectionString() |
|||
{ |
|||
var acme = await _tenantRepository.FindByNameAsync("acme"); |
|||
|
|||
acme.ShouldNotBeNull(); |
|||
acme.FindDefaultConnectionString().ShouldBe("DefaultConnString-Value"); |
|||
} |
|||
|
|||
[Fact] |
|||
public async Task FindConnectionString() |
|||
{ |
|||
var acme = await _tenantRepository.FindByNameAsync("acme"); |
|||
|
|||
acme.ShouldNotBeNull(); |
|||
acme.FindConnectionString(Data.ConnectionStrings.DefaultConnectionStringName).ShouldBe("DefaultConnString-Value"); |
|||
acme.FindConnectionString("MyConnString").ShouldBe("MyConnString-Value"); |
|||
} |
|||
} |
|||
} |
|||
Loading…
Reference in new issue