1
- using System . Reflection ;
2
1
using Abp . AspNetCore . TestBase ;
3
2
using Abp . Modules ;
4
3
using Abp . Reflection . Extensions ;
5
- using AbpCompanyName . AbpProjectName . EntityFrameworkCore ;
6
4
using AbpCompanyName . AbpProjectName . Web . Startup ;
7
- using Castle . MicroKernel . Registration ;
8
- using Castle . Windsor . MsDependencyInjection ;
9
- using Microsoft . EntityFrameworkCore ;
10
- using Microsoft . Extensions . DependencyInjection ;
11
-
12
5
namespace AbpCompanyName . AbpProjectName . Web . Tests
13
6
{
14
7
[ DependsOn (
@@ -20,33 +13,11 @@ public class AbpProjectNameWebTestModule : AbpModule
20
13
public override void PreInitialize ( )
21
14
{
22
15
Configuration . UnitOfWork . IsTransactional = false ; //EF Core InMemory DB does not support transactions.
23
- SetupInMemoryDb ( ) ;
24
16
}
25
17
26
18
public override void Initialize ( )
27
19
{
28
20
IocManager . RegisterAssemblyByConvention ( typeof ( AbpProjectNameWebTestModule ) . GetAssembly ( ) ) ;
29
21
}
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
- }
51
22
}
52
23
}
0 commit comments