diff --git a/framework/src/Volo.Abp.MultiTenancy/Volo/Abp/MultiTenancy/AbpMultiTenancyModule.cs b/framework/src/Volo.Abp.MultiTenancy/Volo/Abp/MultiTenancy/AbpMultiTenancyModule.cs index a6acd17f51..48b5e2c561 100644 --- a/framework/src/Volo.Abp.MultiTenancy/Volo/Abp/MultiTenancy/AbpMultiTenancyModule.cs +++ b/framework/src/Volo.Abp.MultiTenancy/Volo/Abp/MultiTenancy/AbpMultiTenancyModule.cs @@ -31,7 +31,7 @@ public class AbpMultiTenancyModule : AbpModule Configure(options => { - options.TenantResolvers.Add(new CurrentUserTenantResolveContributor()); + options.TenantResolvers.Insert(0, new CurrentUserTenantResolveContributor()); }); } } diff --git a/framework/test/Volo.Abp.MultiTenancy.Tests/Volo/Abp/MultiTenancy/CurrentUserTenantResolveContributor_Tests.cs b/framework/test/Volo.Abp.MultiTenancy.Tests/Volo/Abp/MultiTenancy/CurrentUserTenantResolveContributor_Tests.cs new file mode 100644 index 0000000000..b865dc3780 --- /dev/null +++ b/framework/test/Volo.Abp.MultiTenancy.Tests/Volo/Abp/MultiTenancy/CurrentUserTenantResolveContributor_Tests.cs @@ -0,0 +1,37 @@ +using System.Linq; +using System.Threading.Tasks; +using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Options; +using Shouldly; +using Volo.Abp.Settings; +using Xunit; + +namespace Volo.Abp.MultiTenancy; + +public class CurrentUserTenantResolveContributor_Tests : MultiTenancyTestBase +{ + protected override void AfterAddApplication(IServiceCollection services) + { + services.Configure(options => + { + options.TenantResolvers.Add(new TestTenantResolveContributor()); + }); + } + + [Fact] + public void CurrentUserTenantResolveContributor_Should_Add_First() + { + var options = GetRequiredService>().Value; + options.TenantResolvers.First().GetType().ShouldBe(typeof(CurrentUserTenantResolveContributor)); + } + + class TestTenantResolveContributor : ITenantResolveContributor + { + public string Name { get; } + + public Task ResolveAsync(ITenantResolveContext context) + { + throw new System.NotImplementedException(); + } + } +} diff --git a/framework/test/Volo.Abp.MultiTenancy.Tests/Volo/Abp/MultiTenancy/TenantSettingValueProvider_Tests.cs b/framework/test/Volo.Abp.MultiTenancy.Tests/Volo/Abp/MultiTenancy/TenantSettingValueProvider_Tests.cs new file mode 100644 index 0000000000..dfdbded93c --- /dev/null +++ b/framework/test/Volo.Abp.MultiTenancy.Tests/Volo/Abp/MultiTenancy/TenantSettingValueProvider_Tests.cs @@ -0,0 +1,21 @@ +using Microsoft.Extensions.Options; +using Shouldly; +using Volo.Abp.Settings; +using Xunit; + +namespace Volo.Abp.MultiTenancy; + +public class TenantSettingValueProvider_Tests : MultiTenancyTestBase +{ + [Fact] + public void TenantSettingValueProvider_Should_Add_Correction() + { + var options = GetRequiredService>().Value; + + options.ValueProviders[0].ShouldBe(typeof(DefaultValueSettingValueProvider)); + options.ValueProviders[1].ShouldBe(typeof(ConfigurationSettingValueProvider)); + options.ValueProviders[2].ShouldBe(typeof(GlobalSettingValueProvider)); + options.ValueProviders[3].ShouldBe(typeof(TenantSettingValueProvider)); + options.ValueProviders[4].ShouldBe(typeof(UserSettingValueProvider)); + } +}