mirror of https://github.com/abpframework/abp.git
12 changed files with 103 additions and 87 deletions
@ -1,12 +1,7 @@ |
|||
using Volo.Abp.TestBase; |
|||
|
|||
namespace Volo.Abp.Identity |
|||
namespace Volo.Abp.Identity |
|||
{ |
|||
public class AbpIdentityApplicationTestBase : AbpIntegratedTest<AbpIdentityApplicationTestModule> |
|||
public class AbpIdentityApplicationTestBase : AbpIdentityCommonTestBase<AbpIdentityApplicationTestModule> |
|||
{ |
|||
protected override void SetAbpApplicationCreationOptions(AbpApplicationCreationOptions options) |
|||
{ |
|||
options.UseAutofac(); |
|||
} |
|||
|
|||
} |
|||
} |
|||
|
|||
@ -1,55 +1,20 @@ |
|||
using System; |
|||
using Microsoft.EntityFrameworkCore; |
|||
using Microsoft.Extensions.DependencyInjection; |
|||
using Microsoft.Extensions.DependencyInjection; |
|||
using Volo.Abp.Autofac; |
|||
using Volo.Abp.EntityFrameworkCore; |
|||
using Volo.Abp.Identity.EntityFrameworkCore; |
|||
using Volo.Abp.Modularity; |
|||
using Volo.Abp.Uow; |
|||
|
|||
namespace Volo.Abp.Identity |
|||
{ |
|||
[DependsOn( |
|||
typeof(AbpIdentityApplicationModule), |
|||
typeof(AbpIdentityEntityFrameworkCoreModule), |
|||
typeof(AbpAutofacModule))] |
|||
typeof(AbpAutofacModule), |
|||
typeof(AbpIdentityDomainTestModule))] |
|||
public class AbpIdentityApplicationTestModule : AbpModule |
|||
{ |
|||
public override void ConfigureServices(IServiceCollection services) |
|||
{ |
|||
services.AddAssemblyOf<AbpIdentityApplicationTestModule>(); |
|||
|
|||
services.AddEntityFrameworkInMemoryDatabase(); |
|||
|
|||
var databaseName = Guid.NewGuid().ToString(); |
|||
|
|||
services.Configure<AbpDbContextOptions>(options => |
|||
{ |
|||
options.Configure(context => |
|||
{ |
|||
context.DbContextOptions.UseInMemoryDatabase(databaseName); |
|||
}); |
|||
}); |
|||
|
|||
services.Configure<UnitOfWorkDefaultOptions>(options => |
|||
{ |
|||
options.TransactionBehavior = UnitOfWorkTransactionBehavior.Disabled; //EF in-memory database does not support transactions
|
|||
}); |
|||
} |
|||
|
|||
public override void OnApplicationInitialization(ApplicationInitializationContext context) |
|||
{ |
|||
SeedTestData(context); |
|||
} |
|||
|
|||
private static void SeedTestData(ApplicationInitializationContext context) |
|||
{ |
|||
using (var scope = context.ServiceProvider.CreateScope()) |
|||
{ |
|||
scope.ServiceProvider |
|||
.GetRequiredService<AbpIdentityTestDataBuilder>() |
|||
.Build(); |
|||
} |
|||
} |
|||
} |
|||
} |
|||
|
|||
@ -0,0 +1,14 @@ |
|||
using Volo.Abp.Modularity; |
|||
using Volo.Abp.TestBase; |
|||
|
|||
namespace Volo.Abp.Identity |
|||
{ |
|||
public abstract class AbpIdentityCommonTestBase<TStartupModule> : AbpIntegratedTest<TStartupModule> |
|||
where TStartupModule : IAbpModule |
|||
{ |
|||
protected override void SetAbpApplicationCreationOptions(AbpApplicationCreationOptions options) |
|||
{ |
|||
options.UseAutofac(); |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,7 @@ |
|||
namespace Volo.Abp.Identity |
|||
{ |
|||
public abstract class AbpIdentityDomainTestBase : AbpIdentityCommonTestBase<AbpIdentityDomainTestModule> |
|||
{ |
|||
|
|||
} |
|||
} |
|||
@ -0,0 +1,55 @@ |
|||
using System; |
|||
using Microsoft.EntityFrameworkCore; |
|||
using Microsoft.Extensions.DependencyInjection; |
|||
using Volo.Abp.Autofac; |
|||
using Volo.Abp.EntityFrameworkCore; |
|||
using Volo.Abp.Identity.EntityFrameworkCore; |
|||
using Volo.Abp.Modularity; |
|||
using Volo.Abp.Uow; |
|||
|
|||
namespace Volo.Abp.Identity |
|||
{ |
|||
[DependsOn( |
|||
typeof(AbpIdentityDomainModule), |
|||
typeof(AbpIdentityEntityFrameworkCoreModule), |
|||
typeof(AbpAutofacModule))] |
|||
public class AbpIdentityDomainTestModule : AbpModule |
|||
{ |
|||
public override void ConfigureServices(IServiceCollection services) |
|||
{ |
|||
services.AddEntityFrameworkInMemoryDatabase(); |
|||
|
|||
var databaseName = Guid.NewGuid().ToString(); |
|||
|
|||
services.Configure<AbpDbContextOptions>(options => |
|||
{ |
|||
options.Configure(context => |
|||
{ |
|||
context.DbContextOptions.UseInMemoryDatabase(databaseName); |
|||
}); |
|||
}); |
|||
|
|||
services.Configure<UnitOfWorkDefaultOptions>(options => |
|||
{ |
|||
options.TransactionBehavior = UnitOfWorkTransactionBehavior.Disabled; //EF in-memory database does not support transactions
|
|||
}); |
|||
|
|||
services.AddAssemblyOf<AbpIdentityDomainTestModule>(); |
|||
} |
|||
|
|||
public override void OnApplicationInitialization(ApplicationInitializationContext context) |
|||
{ |
|||
SeedTestData(context); |
|||
} |
|||
|
|||
private static void SeedTestData(ApplicationInitializationContext context) |
|||
{ |
|||
using (var scope = context.ServiceProvider.CreateScope()) |
|||
{ |
|||
scope.ServiceProvider |
|||
.GetRequiredService<AbpIdentityTestDataBuilder>() |
|||
.Build(); |
|||
} |
|||
} |
|||
} |
|||
} |
|||
@ -1,32 +0,0 @@ |
|||
using System; |
|||
using Microsoft.EntityFrameworkCore; |
|||
using Microsoft.Extensions.DependencyInjection; |
|||
using Volo.Abp.Data; |
|||
using Volo.Abp.EntityFrameworkCore; |
|||
using Volo.Abp.Identity.EntityFrameworkCore; |
|||
using Volo.Abp.Modularity; |
|||
|
|||
namespace Volo.Abp.Identity |
|||
{ |
|||
[DependsOn(typeof(AbpIdentityDomainModule), typeof(AbpIdentityEntityFrameworkCoreModule))] |
|||
public class AbpIdentityTestModule : AbpModule |
|||
{ |
|||
public override void ConfigureServices(IServiceCollection services) |
|||
{ |
|||
services.AddEntityFrameworkInMemoryDatabase(); |
|||
|
|||
services.Configure<DbConnectionOptions>(options => |
|||
{ |
|||
options.ConnectionStrings.Default = Guid.NewGuid().ToString(); |
|||
}); |
|||
|
|||
services.Configure<AbpDbContextOptions>(options => |
|||
{ |
|||
options.Configure(context => |
|||
{ |
|||
context.DbContextOptions.UseInMemoryDatabase(context.ConnectionString); |
|||
}); |
|||
}); |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,10 @@ |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.Text; |
|||
|
|||
namespace Volo.Abp.Identity |
|||
{ |
|||
public class PermissionManager_Tests |
|||
{ |
|||
} |
|||
} |
|||
Loading…
Reference in new issue