diff --git a/modules/feature-management/src/Volo.Abp.FeatureManagement.Domain/Volo/Abp/FeatureManagement/FeatureValueCacheItem.cs b/modules/feature-management/src/Volo.Abp.FeatureManagement.Domain/Volo/Abp/FeatureManagement/FeatureValueCacheItem.cs index 765e6c9b32..98d3c07e64 100644 --- a/modules/feature-management/src/Volo.Abp.FeatureManagement.Domain/Volo/Abp/FeatureManagement/FeatureValueCacheItem.cs +++ b/modules/feature-management/src/Volo.Abp.FeatureManagement.Domain/Volo/Abp/FeatureManagement/FeatureValueCacheItem.cs @@ -1,8 +1,10 @@ using System; +using Volo.Abp.MultiTenancy; namespace Volo.Abp.FeatureManagement { [Serializable] + [IgnoreMultiTenancy] public class FeatureValueCacheItem { public string Value { get; set; } diff --git a/modules/feature-management/test/Volo.Abp.FeatureManagement.Domain.Tests/Volo/Abp/FeatureManagement/FeatureManager_Tests.cs b/modules/feature-management/test/Volo.Abp.FeatureManagement.Domain.Tests/Volo/Abp/FeatureManagement/FeatureManager_Tests.cs index b682a82bcf..ac75fdd86e 100644 --- a/modules/feature-management/test/Volo.Abp.FeatureManagement.Domain.Tests/Volo/Abp/FeatureManagement/FeatureManager_Tests.cs +++ b/modules/feature-management/test/Volo.Abp.FeatureManagement.Domain.Tests/Volo/Abp/FeatureManagement/FeatureManager_Tests.cs @@ -1,6 +1,8 @@ -using System.Threading.Tasks; +using System; +using System.Threading.Tasks; using Shouldly; using Volo.Abp.Features; +using Volo.Abp.MultiTenancy; using Xunit; namespace Volo.Abp.FeatureManagement @@ -8,10 +10,14 @@ namespace Volo.Abp.FeatureManagement public class FeatureManager_Tests : FeatureManagementDomainTestBase { private readonly IFeatureManager _featureManager; + private readonly ICurrentTenant _currentTenant; + private readonly IFeatureChecker _featureChecker; public FeatureManager_Tests() { _featureManager = GetRequiredService(); + _featureChecker = GetRequiredService(); + _currentTenant = GetRequiredService(); } [Fact] @@ -79,5 +85,31 @@ namespace Volo.Abp.FeatureManagement TestEditionIds.Ultimate ).ConfigureAwait(false)).ShouldBe("10"); } + + [Fact] + public async Task Should_Change_Feature_Value_And_Refresh_Cache() + { + var tenantId = Guid.NewGuid(); + + //It is "False" at the beginning + using (_currentTenant.Change(tenantId)) + { + (await _featureChecker.IsEnabledAsync(TestFeatureDefinitionProvider.SocialLogins)).ShouldBeFalse(); + } + + //Set to "True" by host for the tenant + using (_currentTenant.Change(null)) + { + (await _featureChecker.IsEnabledAsync(TestFeatureDefinitionProvider.SocialLogins)).ShouldBeFalse(); + await _featureManager.SetForTenantAsync(tenantId, TestFeatureDefinitionProvider.SocialLogins, "True"); + (await _featureManager.GetOrNullForTenantAsync(TestFeatureDefinitionProvider.SocialLogins, tenantId)).ShouldBe("True"); + } + + //Now, it should be "True" + using (_currentTenant.Change(tenantId)) + { + (await _featureChecker.IsEnabledAsync(TestFeatureDefinitionProvider.SocialLogins)).ShouldBeTrue(); + } + } } }