Use the unified provider key format in the feature module.

pull/2371/head
maliming 5 years ago
parent 250ac1a898
commit 542ea712b5

@ -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());
}
}
}

@ -19,7 +19,7 @@ namespace Volo.Abp.Features
public override async Task<string> GetOrNullAsync(FeatureDefinition feature)
{
return await FeatureStore.GetOrNullAsync(feature.Name, Name, CurrentTenant.Id?.ToString("N"));
return await FeatureStore.GetOrNullAsync(feature.Name, Name, CurrentTenant.Id?.ToString());
}
}
}

@ -20,9 +20,9 @@ namespace Volo.Abp.Features
{
_settingRecords = new List<SettingRecord>
{
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")
};
}

@ -26,7 +26,7 @@ namespace Volo.Abp.FeatureManagement
return providerKey;
}
return PrincipalAccessor.Principal?.FindEditionId()?.ToString("N");
return PrincipalAccessor.Principal?.FindEditionId()?.ToString();
}
}
}

@ -10,17 +10,17 @@ namespace Volo.Abp.FeatureManagement
{
public static Task<string> 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<List<FeatureNameValue>> 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);
}
}
}

@ -25,7 +25,7 @@ namespace Volo.Abp.FeatureManagement
return providerKey;
}
return CurrentTenant.Id?.ToString("N");
return CurrentTenant.Id?.ToString();
}
}
}

@ -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<UpdateFeatureDto>()
{
@ -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();

@ -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();
}
}

@ -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();
}

@ -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()
)
);

@ -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);

Loading…
Cancel
Save