using System; using System.Collections.Generic; using System.Linq; using Volo.Abp.Session; using Volo.Abp.Settings.EntityFrameworkCore; using Volo.Abp.TestBase; namespace Volo.Abp.Settings { public class SettingsTestBase : AbpIntegratedTest { protected override void SetAbpApplicationCreationOptions(AbpApplicationCreationOptions options) { options.UseAutofac(); } protected virtual void UsingDbContext(Action action) { using (var dbContext = GetRequiredService()) { action.Invoke(dbContext); } } protected virtual T UsingDbContext(Func action) { using (var dbContext = GetRequiredService()) { return action.Invoke(dbContext); } } protected List GetSettingsFromDbContext(string entityType, string entityId, string name) { return UsingDbContext(context => context.Settings.Where( s => s.ProviderName == UserSettingValueProvider.ProviderName && s.ProviderKey == SettingTestDataBuilder.User1Id.ToString() && s.Name == "MySetting2" ).ToList() ); } } }