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.
52 lines
1.7 KiB
52 lines
1.7 KiB
using Microsoft.Data.Sqlite;
|
|
using Microsoft.EntityFrameworkCore;
|
|
using Microsoft.EntityFrameworkCore.Infrastructure;
|
|
using Microsoft.EntityFrameworkCore.Storage;
|
|
using Volo.Abp.EntityFrameworkCore;
|
|
using Volo.Abp.Identity;
|
|
using Volo.Abp.Identity.AspNetCore;
|
|
using Volo.Abp.Identity.EntityFrameworkCore;
|
|
using Volo.Abp.Modularity;
|
|
using Volo.Abp.PermissionManagement.EntityFrameworkCore;
|
|
|
|
namespace Volo.Abp.Account
|
|
{
|
|
[DependsOn(
|
|
typeof(AbpIdentityAspNetCoreModule),
|
|
typeof(AbpAccountApplicationModule),
|
|
typeof(AbpIdentityDomainTestModule)
|
|
)]
|
|
public class AbpAccountApplicationTestModule : AbpModule
|
|
{
|
|
public override void ConfigureServices(ServiceConfigurationContext context)
|
|
{
|
|
var sqliteConnection = CreateDatabaseAndGetConnection();
|
|
|
|
Configure<AbpDbContextOptions>(options =>
|
|
{
|
|
options.Configure(abpDbContextConfigurationContext =>
|
|
{
|
|
abpDbContextConfigurationContext.DbContextOptions.UseSqlite(sqliteConnection);
|
|
});
|
|
});
|
|
}
|
|
|
|
private static SqliteConnection CreateDatabaseAndGetConnection()
|
|
{
|
|
var connection = new SqliteConnection("Data Source=:memory:");
|
|
connection.Open();
|
|
|
|
new IdentityDbContext(
|
|
new DbContextOptionsBuilder<IdentityDbContext>().UseSqlite(connection).Options
|
|
).GetService<IRelationalDatabaseCreator>().CreateTables();
|
|
|
|
new PermissionManagementDbContext(
|
|
new DbContextOptionsBuilder<PermissionManagementDbContext>().UseSqlite(connection).Options
|
|
).GetService<IRelationalDatabaseCreator>().CreateTables();
|
|
|
|
|
|
return connection;
|
|
}
|
|
}
|
|
}
|