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/SettingTestDataBuilder.cs

83 lines
2.5 KiB

using Volo.Abp.DependencyInjection;
using Volo.Abp.Guids;
using Volo.Abp.Settings;
namespace Volo.Abp.SettingManagement
{
public class SettingTestDataBuilder : ITransientDependency
{
private readonly ISettingRepository _settingRepository;
private readonly IGuidGenerator _guidGenerator;
private readonly SettingTestData _testData;
public SettingTestDataBuilder(
ISettingRepository settingRepository,
IGuidGenerator guidGenerator,
SettingTestData testData)
{
_settingRepository = settingRepository;
_guidGenerator = guidGenerator;
_testData = testData;
}
public void Build()
{
_settingRepository.InsertAsync(
new Setting(
_guidGenerator.Create(),
"MySetting1",
"42",
GlobalSettingValueProvider.ProviderName
)
);
_settingRepository.InsertAsync(
new Setting(
_guidGenerator.Create(),
"MySetting2",
"default-store-value",
GlobalSettingValueProvider.ProviderName
)
);
_settingRepository.InsertAsync(
new Setting(
_guidGenerator.Create(),
"MySetting2",
"user1-store-value",
"User",
_testData.User1Id.ToString()
)
);
_settingRepository.InsertAsync(
new Setting(
_guidGenerator.Create(),
"MySetting2",
"user2-store-value",
"User",
_testData.User2Id.ToString()
)
);
_settingRepository.InsertAsync(
new Setting(
_guidGenerator.Create(),
"MySettingWithoutInherit",
"default-store-value",
GlobalSettingValueProvider.ProviderName
)
);
_settingRepository.InsertAsync(
new Setting(
_guidGenerator.Create(),
"MySettingWithoutInherit",
"user1-store-value",
"User",
_testData.User1Id.ToString()
)
);
}
}
}