You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
abp/modules/setting-management/test/Volo.Abp.SettingManagement..../Volo/Abp/SettingManagement/SettingsTestBase.cs

39 lines
1.2 KiB

using System;
using System.Collections.Generic;
using System.Linq;
using Volo.Abp.SettingManagement.EntityFrameworkCore;
namespace Volo.Abp.SettingManagement
{
public class SettingsTestBase : SettingManagementTestBase<AbpSettingManagementTestModule>
{
protected virtual void UsingDbContext(Action<ISettingManagementDbContext> action)
{
using (var dbContext = GetRequiredService<ISettingManagementDbContext>())
{
action.Invoke(dbContext);
}
}
protected virtual T UsingDbContext<T>(Func<ISettingManagementDbContext, T> action)
{
using (var dbContext = GetRequiredService<ISettingManagementDbContext>())
{
return action.Invoke(dbContext);
}
}
protected List<Setting> GetSettingsFromDbContext(string entityType, string entityId, string name)
{
return UsingDbContext(context =>
context.Settings.Where(
s =>
s.ProviderName == entityType &&
s.ProviderKey == entityId &&
s.Name == name
).ToList()
);
}
}
}