1- using System . Reflection ;
21using Abp . AspNetCore . TestBase ;
32using Abp . Modules ;
43using Abp . Reflection . Extensions ;
5- using AbpCompanyName . AbpProjectName . EntityFrameworkCore ;
64using AbpCompanyName . AbpProjectName . Web . Startup ;
7- using Castle . MicroKernel . Registration ;
8- using Castle . Windsor . MsDependencyInjection ;
9- using Microsoft . EntityFrameworkCore ;
10- using Microsoft . Extensions . DependencyInjection ;
11-
125namespace AbpCompanyName . AbpProjectName . Web . Tests
136{
147 [ DependsOn (
@@ -20,33 +13,11 @@ public class AbpProjectNameWebTestModule : AbpModule
2013 public override void PreInitialize ( )
2114 {
2215 Configuration . UnitOfWork . IsTransactional = false ; //EF Core InMemory DB does not support transactions.
23- SetupInMemoryDb ( ) ;
2416 }
2517
2618 public override void Initialize ( )
2719 {
2820 IocManager . RegisterAssemblyByConvention ( typeof ( AbpProjectNameWebTestModule ) . GetAssembly ( ) ) ;
2921 }
30-
31- private void SetupInMemoryDb ( )
32- {
33- var services = new ServiceCollection ( )
34- . AddEntityFrameworkInMemoryDatabase ( ) ;
35-
36- var serviceProvider = WindsorRegistrationHelper . CreateServiceProvider (
37- IocManager . IocContainer ,
38- services
39- ) ;
40-
41- var builder = new DbContextOptionsBuilder < AbpProjectNameDbContext > ( ) ;
42- builder . UseInMemoryDatabase ( ) . UseInternalServiceProvider ( serviceProvider ) ;
43-
44- IocManager . IocContainer . Register (
45- Component
46- . For < DbContextOptions < AbpProjectNameDbContext > > ( )
47- . Instance ( builder . Options )
48- . LifestyleSingleton ( )
49- ) ;
50- }
5122 }
5223}
0 commit comments