mirror of https://github.com/abpframework/abp
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.
64 lines
1.9 KiB
64 lines
1.9 KiB
using Microsoft.Extensions.DependencyInjection;
|
|
using NSubstitute;
|
|
using Volo.Abp;
|
|
using Volo.Abp.Authorization;
|
|
using Volo.Abp.Autofac;
|
|
using Volo.Abp.BlobStoring;
|
|
using Volo.Abp.Data;
|
|
using Volo.Abp.GlobalFeatures;
|
|
using Volo.Abp.Modularity;
|
|
using Volo.Abp.Threading;
|
|
using Volo.FileManagement;
|
|
|
|
namespace Volo.CmsKit
|
|
{
|
|
[DependsOn(
|
|
typeof(AbpAutofacModule),
|
|
typeof(AbpTestBaseModule),
|
|
typeof(AbpAuthorizationModule),
|
|
typeof(CmsKitDomainModule)
|
|
)]
|
|
public class CmsKitTestBaseModule : AbpModule
|
|
{
|
|
private static readonly OneTimeRunner OneTimeRunner = new OneTimeRunner();
|
|
|
|
public override void ConfigureServices(ServiceConfigurationContext context)
|
|
{
|
|
OneTimeRunner.Run(() =>
|
|
{
|
|
GlobalFeatureManager.Instance.Modules.CmsKit().EnableAll();
|
|
});
|
|
|
|
context.Services.AddSingleton<IBlobProvider>(Substitute.For<FakeBlobProvider>());
|
|
|
|
Configure<AbpBlobStoringOptions>(options =>
|
|
{
|
|
options.Containers.ConfigureAll((containerName, containerConfiguration) =>
|
|
{
|
|
containerConfiguration.ProviderType = typeof(FakeBlobProvider);
|
|
});
|
|
});
|
|
|
|
context.Services.AddAlwaysAllowAuthorization();
|
|
}
|
|
|
|
public override void OnApplicationInitialization(ApplicationInitializationContext context)
|
|
{
|
|
SeedTestData(context);
|
|
}
|
|
|
|
private static void SeedTestData(ApplicationInitializationContext context)
|
|
{
|
|
AsyncHelper.RunSync(async () =>
|
|
{
|
|
using (var scope = context.ServiceProvider.CreateScope())
|
|
{
|
|
await scope.ServiceProvider
|
|
.GetRequiredService<IDataSeeder>()
|
|
.SeedAsync();
|
|
}
|
|
});
|
|
}
|
|
}
|
|
}
|