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.
		
		
		
		
		
			
		
			
				
					
					
						
							66 lines
						
					
					
						
							2.0 KiB
						
					
					
				
			
		
		
	
	
							66 lines
						
					
					
						
							2.0 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;
 | |
| 
 | |
| 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 PreConfigureServices(ServiceConfigurationContext context)
 | |
|         {
 | |
|             OneTimeRunner.Run(() =>
 | |
|             {
 | |
|                 GlobalFeatureManager.Instance.Modules.CmsKit().EnableAll();
 | |
|             });
 | |
|         }
 | |
| 
 | |
|         public override void ConfigureServices(ServiceConfigurationContext context)
 | |
|         {
 | |
|             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();
 | |
|                 }
 | |
|             });
 | |
|         }
 | |
|     }
 | |
| }
 |