|
|
|
@ -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<IFeatureManager>(); |
|
|
|
_featureChecker = GetRequiredService<IFeatureChecker>(); |
|
|
|
_currentTenant = GetRequiredService<ICurrentTenant>(); |
|
|
|
} |
|
|
|
|
|
|
|
[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(); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|