From 542ea712b56ce3115e069c586a3fd5a1306c953f Mon Sep 17 00:00:00 2001 From: maliming Date: Wed, 11 Dec 2019 13:40:30 +0800 Subject: [PATCH] Use the unified provider key format in the feature module. --- .../Features/EditionFeatureValueProvider.cs | 2 +- .../Features/TenantFeatureValueProvider.cs | 2 +- .../Volo/Abp/Features/TestFeatureStore.cs | 6 ++-- .../EditionFeatureManagementProvider.cs | 2 +- .../EditionFeatureManagerExtensions.cs | 6 ++-- .../TenantFeatureManagementProvider.cs | 2 +- .../FeatureAppService_Tests.cs | 6 ++-- .../FeatureValueCacheItemInvalidator_Tests.cs | 6 ++-- .../FeatureManagementStore_Tests.cs | 24 ++++++++-------- .../FeatureManagementTestDataBuilder.cs | 28 +++++++++---------- .../FeatureValueRepository_Tests.cs | 4 +-- 11 files changed, 44 insertions(+), 44 deletions(-) diff --git a/framework/src/Volo.Abp.Features/Volo/Abp/Features/EditionFeatureValueProvider.cs b/framework/src/Volo.Abp.Features/Volo/Abp/Features/EditionFeatureValueProvider.cs index ee6150d403..49ea1b3f4c 100644 --- a/framework/src/Volo.Abp.Features/Volo/Abp/Features/EditionFeatureValueProvider.cs +++ b/framework/src/Volo.Abp.Features/Volo/Abp/Features/EditionFeatureValueProvider.cs @@ -26,7 +26,7 @@ namespace Volo.Abp.Features return null; } - return await FeatureStore.GetOrNullAsync(feature.Name, Name, editionId.Value.ToString("N")); + return await FeatureStore.GetOrNullAsync(feature.Name, Name, editionId.Value.ToString()); } } } \ No newline at end of file diff --git a/framework/src/Volo.Abp.Features/Volo/Abp/Features/TenantFeatureValueProvider.cs b/framework/src/Volo.Abp.Features/Volo/Abp/Features/TenantFeatureValueProvider.cs index d403acb993..5ae4b5f876 100644 --- a/framework/src/Volo.Abp.Features/Volo/Abp/Features/TenantFeatureValueProvider.cs +++ b/framework/src/Volo.Abp.Features/Volo/Abp/Features/TenantFeatureValueProvider.cs @@ -19,7 +19,7 @@ namespace Volo.Abp.Features public override async Task GetOrNullAsync(FeatureDefinition feature) { - return await FeatureStore.GetOrNullAsync(feature.Name, Name, CurrentTenant.Id?.ToString("N")); + return await FeatureStore.GetOrNullAsync(feature.Name, Name, CurrentTenant.Id?.ToString()); } } } \ No newline at end of file diff --git a/framework/test/Volo.Abp.Features.Tests/Volo/Abp/Features/TestFeatureStore.cs b/framework/test/Volo.Abp.Features.Tests/Volo/Abp/Features/TestFeatureStore.cs index 4592a18365..87fef33a8d 100644 --- a/framework/test/Volo.Abp.Features.Tests/Volo/Abp/Features/TestFeatureStore.cs +++ b/framework/test/Volo.Abp.Features.Tests/Volo/Abp/Features/TestFeatureStore.cs @@ -20,9 +20,9 @@ namespace Volo.Abp.Features { _settingRecords = new List { - new SettingRecord("BooleanTestFeature1", TenantFeatureValueProvider.ProviderName, Tenant1Id.ToString("N"), "true"), - new SettingRecord("BooleanTestFeature2", TenantFeatureValueProvider.ProviderName, Tenant1Id.ToString("N"), "true"), - new SettingRecord("IntegerTestFeature1", TenantFeatureValueProvider.ProviderName, Tenant2Id.ToString("N"), "34") + new SettingRecord("BooleanTestFeature1", TenantFeatureValueProvider.ProviderName, Tenant1Id.ToString(), "true"), + new SettingRecord("BooleanTestFeature2", TenantFeatureValueProvider.ProviderName, Tenant1Id.ToString(), "true"), + new SettingRecord("IntegerTestFeature1", TenantFeatureValueProvider.ProviderName, Tenant2Id.ToString(), "34") }; } diff --git a/modules/feature-management/src/Volo.Abp.FeatureManagement.Domain/Volo/Abp/FeatureManagement/EditionFeatureManagementProvider.cs b/modules/feature-management/src/Volo.Abp.FeatureManagement.Domain/Volo/Abp/FeatureManagement/EditionFeatureManagementProvider.cs index d904ef124a..cef7983235 100644 --- a/modules/feature-management/src/Volo.Abp.FeatureManagement.Domain/Volo/Abp/FeatureManagement/EditionFeatureManagementProvider.cs +++ b/modules/feature-management/src/Volo.Abp.FeatureManagement.Domain/Volo/Abp/FeatureManagement/EditionFeatureManagementProvider.cs @@ -26,7 +26,7 @@ namespace Volo.Abp.FeatureManagement return providerKey; } - return PrincipalAccessor.Principal?.FindEditionId()?.ToString("N"); + return PrincipalAccessor.Principal?.FindEditionId()?.ToString(); } } } \ No newline at end of file diff --git a/modules/feature-management/src/Volo.Abp.FeatureManagement.Domain/Volo/Abp/FeatureManagement/EditionFeatureManagerExtensions.cs b/modules/feature-management/src/Volo.Abp.FeatureManagement.Domain/Volo/Abp/FeatureManagement/EditionFeatureManagerExtensions.cs index 9cad051d5f..be8bbfc95a 100644 --- a/modules/feature-management/src/Volo.Abp.FeatureManagement.Domain/Volo/Abp/FeatureManagement/EditionFeatureManagerExtensions.cs +++ b/modules/feature-management/src/Volo.Abp.FeatureManagement.Domain/Volo/Abp/FeatureManagement/EditionFeatureManagerExtensions.cs @@ -10,17 +10,17 @@ namespace Volo.Abp.FeatureManagement { public static Task GetOrNullForEditionAsync(this IFeatureManager featureManager, [NotNull] string name, Guid editionId, bool fallback = true) { - return featureManager.GetOrNullAsync(name, EditionFeatureValueProvider.ProviderName, editionId.ToString("N"), fallback); + return featureManager.GetOrNullAsync(name, EditionFeatureValueProvider.ProviderName, editionId.ToString(), fallback); } public static Task> GetAllForEditionAsync(this IFeatureManager featureManager, Guid editionId, bool fallback = true) { - return featureManager.GetAllAsync(EditionFeatureValueProvider.ProviderName, editionId.ToString("N"), fallback); + return featureManager.GetAllAsync(EditionFeatureValueProvider.ProviderName, editionId.ToString(), fallback); } public static Task SetForEditionAsync(this IFeatureManager featureManager, Guid editionId, [NotNull] string name, [CanBeNull] string value, bool forceToSet = false) { - return featureManager.SetAsync(name, value, EditionFeatureValueProvider.ProviderName, editionId.ToString("N"), forceToSet); + return featureManager.SetAsync(name, value, EditionFeatureValueProvider.ProviderName, editionId.ToString(), forceToSet); } } } \ No newline at end of file diff --git a/modules/feature-management/src/Volo.Abp.FeatureManagement.Domain/Volo/Abp/FeatureManagement/TenantFeatureManagementProvider.cs b/modules/feature-management/src/Volo.Abp.FeatureManagement.Domain/Volo/Abp/FeatureManagement/TenantFeatureManagementProvider.cs index e625e47880..91302580d2 100644 --- a/modules/feature-management/src/Volo.Abp.FeatureManagement.Domain/Volo/Abp/FeatureManagement/TenantFeatureManagementProvider.cs +++ b/modules/feature-management/src/Volo.Abp.FeatureManagement.Domain/Volo/Abp/FeatureManagement/TenantFeatureManagementProvider.cs @@ -25,7 +25,7 @@ namespace Volo.Abp.FeatureManagement return providerKey; } - return CurrentTenant.Id?.ToString("N"); + return CurrentTenant.Id?.ToString(); } } } \ No newline at end of file diff --git a/modules/feature-management/test/Volo.Abp.FeatureManagement.Application.Tests/Volo/Abp/FeatureManagement/FeatureAppService_Tests.cs b/modules/feature-management/test/Volo.Abp.FeatureManagement.Application.Tests/Volo/Abp/FeatureManagement/FeatureAppService_Tests.cs index 5198ea7277..b86e6be013 100644 --- a/modules/feature-management/test/Volo.Abp.FeatureManagement.Application.Tests/Volo/Abp/FeatureManagement/FeatureAppService_Tests.cs +++ b/modules/feature-management/test/Volo.Abp.FeatureManagement.Application.Tests/Volo/Abp/FeatureManagement/FeatureAppService_Tests.cs @@ -39,7 +39,7 @@ namespace Volo.Abp.FeatureManagement Login(_testData.User1Id); var featureList = await _featureAppService.GetAsync(EditionFeatureValueProvider.ProviderName, - TestEditionIds.Regular.ToString("N")); + TestEditionIds.Regular.ToString()); featureList.ShouldNotBeNull(); featureList.Features.ShouldContain(feature => feature.Name == TestFeatureDefinitionProvider.SocialLogins); @@ -51,7 +51,7 @@ namespace Volo.Abp.FeatureManagement Login(_testData.User1Id); await _featureAppService.UpdateAsync(EditionFeatureValueProvider.ProviderName, - TestEditionIds.Regular.ToString("N"), new UpdateFeaturesDto() + TestEditionIds.Regular.ToString(), new UpdateFeaturesDto() { Features = new List() { @@ -64,7 +64,7 @@ namespace Volo.Abp.FeatureManagement }); (await _featureAppService.GetAsync(EditionFeatureValueProvider.ProviderName, - TestEditionIds.Regular.ToString("N"))).Features.Any(x => + TestEditionIds.Regular.ToString())).Features.Any(x => x.Name == TestFeatureDefinitionProvider.SocialLogins && x.Value == false.ToString().ToLowerInvariant()) .ShouldBeTrue(); diff --git a/modules/feature-management/test/Volo.Abp.FeatureManagement.Domain.Tests/Volo/Abp/FeatureManagement/FeatureValueCacheItemInvalidator_Tests.cs b/modules/feature-management/test/Volo.Abp.FeatureManagement.Domain.Tests/Volo/Abp/FeatureManagement/FeatureValueCacheItemInvalidator_Tests.cs index d6666c6c09..ce74094f97 100644 --- a/modules/feature-management/test/Volo.Abp.FeatureManagement.Domain.Tests/Volo/Abp/FeatureManagement/FeatureValueCacheItemInvalidator_Tests.cs +++ b/modules/feature-management/test/Volo.Abp.FeatureManagement.Domain.Tests/Volo/Abp/FeatureManagement/FeatureValueCacheItemInvalidator_Tests.cs @@ -28,11 +28,11 @@ namespace Volo.Abp.FeatureManagement // Arrange cache feature. await _featureManagementStore.GetOrNullAsync(TestFeatureDefinitionProvider.SocialLogins, EditionFeatureValueProvider.ProviderName, - TestEditionIds.Regular.ToString("N")); + TestEditionIds.Regular.ToString()); var feature = await _featureValueRepository.FindAsync(TestFeatureDefinitionProvider.SocialLogins, EditionFeatureValueProvider.ProviderName, - TestEditionIds.Regular.ToString("N")); + TestEditionIds.Regular.ToString()); // Act await _featureValueRepository.DeleteAsync(feature); @@ -40,7 +40,7 @@ namespace Volo.Abp.FeatureManagement // Assert (await _cache.GetAsync(FeatureValueCacheItem.CalculateCacheKey(TestFeatureDefinitionProvider.SocialLogins, EditionFeatureValueProvider.ProviderName, - TestEditionIds.Regular.ToString("N")))).ShouldBeNull(); + TestEditionIds.Regular.ToString()))).ShouldBeNull(); } } diff --git a/modules/feature-management/test/Volo.Abp.FeatureManagement.TestBase/Volo/Abp/FeatureManagement/FeatureManagementStore_Tests.cs b/modules/feature-management/test/Volo.Abp.FeatureManagement.TestBase/Volo/Abp/FeatureManagement/FeatureManagementStore_Tests.cs index c03c5dea65..a6f040dde3 100644 --- a/modules/feature-management/test/Volo.Abp.FeatureManagement.TestBase/Volo/Abp/FeatureManagement/FeatureManagementStore_Tests.cs +++ b/modules/feature-management/test/Volo.Abp.FeatureManagement.TestBase/Volo/Abp/FeatureManagement/FeatureManagementStore_Tests.cs @@ -25,13 +25,13 @@ namespace Volo.Abp.FeatureManagement public async Task GetOrNullAsync() { // Act - (await FeatureManagementStore.GetOrNullAsync(Guid.NewGuid().ToString("N"), + (await FeatureManagementStore.GetOrNullAsync(Guid.NewGuid().ToString(), EditionFeatureValueProvider.ProviderName, - TestEditionIds.Regular.ToString("N"))).ShouldBeNull(); + TestEditionIds.Regular.ToString())).ShouldBeNull(); (await FeatureManagementStore.GetOrNullAsync(TestFeatureDefinitionProvider.SocialLogins, EditionFeatureValueProvider.ProviderName, - TestEditionIds.Regular.ToString("N"))).ShouldNotBeNull(); + TestEditionIds.Regular.ToString())).ShouldNotBeNull(); } [Fact] @@ -40,17 +40,17 @@ namespace Volo.Abp.FeatureManagement // Arrange (await FeatureManagementStore.GetOrNullAsync(TestFeatureDefinitionProvider.SocialLogins, EditionFeatureValueProvider.ProviderName, - TestEditionIds.Regular.ToString("N"))).ShouldNotBeNull(); + TestEditionIds.Regular.ToString())).ShouldNotBeNull(); // Act await FeatureManagementStore.DeleteAsync(TestFeatureDefinitionProvider.SocialLogins, EditionFeatureValueProvider.ProviderName, - TestEditionIds.Regular.ToString("N")); + TestEditionIds.Regular.ToString()); // Assert (await FeatureManagementStore.GetOrNullAsync(TestFeatureDefinitionProvider.SocialLogins, EditionFeatureValueProvider.ProviderName, - TestEditionIds.Regular.ToString("N"))).ShouldBeNull(); + TestEditionIds.Regular.ToString())).ShouldBeNull(); } [Fact] @@ -59,18 +59,18 @@ namespace Volo.Abp.FeatureManagement // Arrange (await FeatureValueRepository.FindAsync(TestFeatureDefinitionProvider.SocialLogins, EditionFeatureValueProvider.ProviderName, - TestEditionIds.Regular.ToString("N"))).Value.ShouldBe(true.ToString().ToLowerInvariant()); + TestEditionIds.Regular.ToString())).Value.ShouldBe(true.ToString().ToLowerInvariant()); // Act await FeatureManagementStore.SetAsync(TestFeatureDefinitionProvider.SocialLogins, false.ToString().ToUpperInvariant(), EditionFeatureValueProvider.ProviderName, - TestEditionIds.Regular.ToString("N")); + TestEditionIds.Regular.ToString()); // Assert (await FeatureValueRepository.FindAsync(TestFeatureDefinitionProvider.SocialLogins, EditionFeatureValueProvider.ProviderName, - TestEditionIds.Regular.ToString("N"))).Value.ShouldBe(false.ToString().ToUpperInvariant()); + TestEditionIds.Regular.ToString())).Value.ShouldBe(false.ToString().ToUpperInvariant()); } [Fact] @@ -79,18 +79,18 @@ namespace Volo.Abp.FeatureManagement // Arrange (await FeatureValueRepository.FindAsync(TestFeatureDefinitionProvider.SocialLogins, EditionFeatureValueProvider.ProviderName, - TestEditionIds.Regular.ToString("N"))).ShouldNotBeNull(); + TestEditionIds.Regular.ToString())).ShouldNotBeNull(); // Act await FeatureManagementStore.DeleteAsync(TestFeatureDefinitionProvider.SocialLogins, EditionFeatureValueProvider.ProviderName, - TestEditionIds.Regular.ToString("N")); + TestEditionIds.Regular.ToString()); // Assert (await FeatureValueRepository.FindAsync(TestFeatureDefinitionProvider.SocialLogins, EditionFeatureValueProvider.ProviderName, - TestEditionIds.Regular.ToString("N"))).ShouldBeNull(); + TestEditionIds.Regular.ToString())).ShouldBeNull(); } diff --git a/modules/feature-management/test/Volo.Abp.FeatureManagement.TestBase/Volo/Abp/FeatureManagement/FeatureManagementTestDataBuilder.cs b/modules/feature-management/test/Volo.Abp.FeatureManagement.TestBase/Volo/Abp/FeatureManagement/FeatureManagementTestDataBuilder.cs index f402288fa3..6c6a835109 100644 --- a/modules/feature-management/test/Volo.Abp.FeatureManagement.TestBase/Volo/Abp/FeatureManagement/FeatureManagementTestDataBuilder.cs +++ b/modules/feature-management/test/Volo.Abp.FeatureManagement.TestBase/Volo/Abp/FeatureManagement/FeatureManagementTestDataBuilder.cs @@ -31,7 +31,7 @@ namespace Volo.Abp.FeatureManagement TestFeatureDefinitionProvider.SocialLogins, true.ToString().ToLowerInvariant(), EditionFeatureValueProvider.ProviderName, - TestEditionIds.Regular.ToString("N") + TestEditionIds.Regular.ToString() ) ); @@ -42,7 +42,7 @@ namespace Volo.Abp.FeatureManagement TestFeatureDefinitionProvider.UserCount, "10", EditionFeatureValueProvider.ProviderName, - TestEditionIds.Regular.ToString("N") + TestEditionIds.Regular.ToString() ) ); @@ -53,7 +53,7 @@ namespace Volo.Abp.FeatureManagement TestFeatureDefinitionProvider.ProjectCount, "1", EditionFeatureValueProvider.ProviderName, - TestEditionIds.Regular.ToString("N") + TestEditionIds.Regular.ToString() ) ); @@ -68,7 +68,7 @@ namespace Volo.Abp.FeatureManagement TestFeatureDefinitionProvider.SocialLogins, true.ToString().ToLowerInvariant(), EditionFeatureValueProvider.ProviderName, - TestEditionIds.Enterprise.ToString("N") + TestEditionIds.Enterprise.ToString() ) ); @@ -79,7 +79,7 @@ namespace Volo.Abp.FeatureManagement TestFeatureDefinitionProvider.EmailSupport, true.ToString().ToLowerInvariant(), EditionFeatureValueProvider.ProviderName, - TestEditionIds.Enterprise.ToString("N") + TestEditionIds.Enterprise.ToString() ) ); @@ -90,7 +90,7 @@ namespace Volo.Abp.FeatureManagement TestFeatureDefinitionProvider.UserCount, "20", EditionFeatureValueProvider.ProviderName, - TestEditionIds.Enterprise.ToString("N") + TestEditionIds.Enterprise.ToString() ) ); @@ -101,7 +101,7 @@ namespace Volo.Abp.FeatureManagement TestFeatureDefinitionProvider.ProjectCount, "3", EditionFeatureValueProvider.ProviderName, - TestEditionIds.Enterprise.ToString("N") + TestEditionIds.Enterprise.ToString() ) ); @@ -112,7 +112,7 @@ namespace Volo.Abp.FeatureManagement TestFeatureDefinitionProvider.BackupCount, "5", EditionFeatureValueProvider.ProviderName, - TestEditionIds.Enterprise.ToString("N") + TestEditionIds.Enterprise.ToString() ) ); @@ -127,7 +127,7 @@ namespace Volo.Abp.FeatureManagement TestFeatureDefinitionProvider.SocialLogins, true.ToString().ToLowerInvariant(), EditionFeatureValueProvider.ProviderName, - TestEditionIds.Ultimate.ToString("N") + TestEditionIds.Ultimate.ToString() ) ); @@ -138,7 +138,7 @@ namespace Volo.Abp.FeatureManagement TestFeatureDefinitionProvider.EmailSupport, true.ToString().ToLowerInvariant(), EditionFeatureValueProvider.ProviderName, - TestEditionIds.Ultimate.ToString("N") + TestEditionIds.Ultimate.ToString() ) ); @@ -149,7 +149,7 @@ namespace Volo.Abp.FeatureManagement TestFeatureDefinitionProvider.DailyAnalysis, true.ToString().ToLowerInvariant(), EditionFeatureValueProvider.ProviderName, - TestEditionIds.Ultimate.ToString("N") + TestEditionIds.Ultimate.ToString() ) ); @@ -160,7 +160,7 @@ namespace Volo.Abp.FeatureManagement TestFeatureDefinitionProvider.UserCount, "100", EditionFeatureValueProvider.ProviderName, - TestEditionIds.Ultimate.ToString("N") + TestEditionIds.Ultimate.ToString() ) ); @@ -171,7 +171,7 @@ namespace Volo.Abp.FeatureManagement TestFeatureDefinitionProvider.ProjectCount, "10", EditionFeatureValueProvider.ProviderName, - TestEditionIds.Ultimate.ToString("N") + TestEditionIds.Ultimate.ToString() ) ); @@ -182,7 +182,7 @@ namespace Volo.Abp.FeatureManagement TestFeatureDefinitionProvider.BackupCount, "10", EditionFeatureValueProvider.ProviderName, - TestEditionIds.Ultimate.ToString("N") + TestEditionIds.Ultimate.ToString() ) ); diff --git a/modules/feature-management/test/Volo.Abp.FeatureManagement.TestBase/Volo/Abp/FeatureManagement/FeatureValueRepository_Tests.cs b/modules/feature-management/test/Volo.Abp.FeatureManagement.TestBase/Volo/Abp/FeatureManagement/FeatureValueRepository_Tests.cs index 4ec3d2f437..c7cbb0d8ae 100644 --- a/modules/feature-management/test/Volo.Abp.FeatureManagement.TestBase/Volo/Abp/FeatureManagement/FeatureValueRepository_Tests.cs +++ b/modules/feature-management/test/Volo.Abp.FeatureManagement.TestBase/Volo/Abp/FeatureManagement/FeatureValueRepository_Tests.cs @@ -24,7 +24,7 @@ namespace Volo.Abp.FeatureManagement var featureValue = await Repository.FindAsync( TestFeatureDefinitionProvider.ProjectCount, EditionFeatureValueProvider.ProviderName, - TestEditionIds.Enterprise.ToString("N") + TestEditionIds.Enterprise.ToString() ); featureValue.ShouldNotBeNull(); @@ -45,7 +45,7 @@ namespace Volo.Abp.FeatureManagement { var featureValues = await Repository.GetListAsync( EditionFeatureValueProvider.ProviderName, - TestEditionIds.Enterprise.ToString("N") + TestEditionIds.Enterprise.ToString() ); featureValues.Count.ShouldBeGreaterThan(0);