Merge pull request #6202 from abpframework/maliming/GetAllWithProviderAsync

GetOrNullWithProviderAsync can only call Reverse once.
pull/6207/head
Halil İbrahim Kalkan 5 years ago committed by GitHub
commit ff5f53460e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -1,4 +1,4 @@
using System;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
@ -76,16 +76,14 @@ namespace Volo.Abp.FeatureManagement
Check.NotNull(providerName, nameof(providerName));
var featureDefinitions = FeatureDefinitionManager.GetAll();
var providers = Enumerable.Reverse(Providers)
.SkipWhile(c => c.Name != providerName);
var providers = Enumerable.Reverse(Providers).SkipWhile(c => c.Name != providerName);
if (!fallback)
{
providers = providers.TakeWhile(c => c.Name == providerName);
}
var providerList = providers.Reverse().ToList();
var providerList = providers.ToList();
if (!providerList.Any())
{
return new List<FeatureNameValueWithGrantedProvider>();

@ -1,4 +1,5 @@
using System;
using System.Linq;
using System.Threading.Tasks;
using Shouldly;
using Volo.Abp.Features;
@ -111,5 +112,47 @@ namespace Volo.Abp.FeatureManagement
(await _featureChecker.IsEnabledAsync(TestFeatureDefinitionProvider.SocialLogins)).ShouldBeTrue();
}
}
[Fact]
public async Task Should_Get_FeatureValues_With_Provider_For_A_Provider()
{
var featureNameValueWithGrantedProviders = await _featureManager.GetAllWithProviderAsync(
EditionFeatureValueProvider.ProviderName,
TestEditionIds.Enterprise.ToString()
);
featureNameValueWithGrantedProviders.ShouldContain(x =>
x.Name == TestFeatureDefinitionProvider.SocialLogins
&& x.Value == true.ToString().ToLowerInvariant() &&
x.Provider.Name == EditionFeatureValueProvider.ProviderName);
featureNameValueWithGrantedProviders.ShouldContain(x =>
x.Name == TestFeatureDefinitionProvider.EmailSupport &&
x.Value == true.ToString().ToLowerInvariant() &&
x.Provider.Name == EditionFeatureValueProvider.ProviderName);
//Default Value
featureNameValueWithGrantedProviders.ShouldContain(x =>
x.Name == TestFeatureDefinitionProvider.DailyAnalysis &&
x.Value == false.ToString().ToLowerInvariant() &&
x.Provider.Name == DefaultValueFeatureValueProvider.ProviderName);
featureNameValueWithGrantedProviders.ShouldContain(x =>
x.Name == TestFeatureDefinitionProvider.UserCount &&
x.Value == "20" &&
x.Provider.Name == EditionFeatureValueProvider.ProviderName);
featureNameValueWithGrantedProviders.ShouldContain(x =>
x.Name == TestFeatureDefinitionProvider.ProjectCount &&
x.Value == "3" &&
x.Provider.Name == EditionFeatureValueProvider.ProviderName);
featureNameValueWithGrantedProviders.ShouldContain(x =>
x.Name == TestFeatureDefinitionProvider.BackupCount &&
x.Value == "5" &&
x.Provider.Name == EditionFeatureValueProvider.ProviderName);
}
}
}

@ -41,7 +41,7 @@ namespace Volo.Abp.FeatureManagement
}
[Fact]
public async Task FindAAllsync()
public async Task FindAllAsync()
{
var featureValues = await Repository.FindAllAsync(
TestFeatureDefinitionProvider.ProjectCount,

Loading…
Cancel
Save