mirror of https://github.com/abpframework/abp.git
7 changed files with 90 additions and 25 deletions
@ -0,0 +1,70 @@ |
|||
using System; |
|||
using System.Threading.Tasks; |
|||
using Microsoft.Extensions.DependencyInjection; |
|||
using Volo.Abp.Modularity; |
|||
|
|||
namespace Volo.Abp.Testing; |
|||
|
|||
public class AbpAsyncIntegratedTest<TStartupModule> : AbpTestBaseWithServiceProvider |
|||
where TStartupModule : IAbpModule |
|||
{ |
|||
protected IAbpApplication Application { get; set; } |
|||
|
|||
protected IServiceProvider RootServiceProvider { get; set; } |
|||
|
|||
protected IServiceScope TestServiceScope { get; set; } |
|||
|
|||
public virtual async Task InitializeAsync() |
|||
{ |
|||
var services = await CreateServiceCollectionAsync(); |
|||
|
|||
await BeforeAddApplicationAsync(services); |
|||
var application = await services.AddApplicationAsync<TStartupModule>(await SetAbpApplicationCreationOptionsAsync()); |
|||
await AfterAddApplicationAsync(services); |
|||
|
|||
RootServiceProvider = await CreateServiceProviderAsync(services); |
|||
TestServiceScope = RootServiceProvider.CreateScope(); |
|||
await application.InitializeAsync(TestServiceScope.ServiceProvider); |
|||
ServiceProvider = application.ServiceProvider; |
|||
Application = application; |
|||
|
|||
await InitializeServicesAsync(); |
|||
} |
|||
|
|||
public virtual async Task DisposeAsync() |
|||
{ |
|||
await Application.ShutdownAsync(); |
|||
TestServiceScope.Dispose(); |
|||
Application.Dispose(); |
|||
} |
|||
|
|||
protected virtual Task<IServiceCollection> CreateServiceCollectionAsync() |
|||
{ |
|||
return Task.FromResult<IServiceCollection>(new ServiceCollection()); |
|||
} |
|||
|
|||
protected virtual Task BeforeAddApplicationAsync(IServiceCollection services) |
|||
{ |
|||
return Task.CompletedTask; |
|||
} |
|||
|
|||
protected virtual Task<Action<AbpApplicationCreationOptions>> SetAbpApplicationCreationOptionsAsync() |
|||
{ |
|||
return Task.FromResult<Action<AbpApplicationCreationOptions>>(_ => { }); |
|||
} |
|||
|
|||
protected virtual Task AfterAddApplicationAsync(IServiceCollection services) |
|||
{ |
|||
return Task.CompletedTask; |
|||
} |
|||
|
|||
protected virtual Task<IServiceProvider> CreateServiceProviderAsync(IServiceCollection services) |
|||
{ |
|||
return Task.FromResult(services.BuildServiceProviderFromFactory()); |
|||
} |
|||
|
|||
protected virtual Task InitializeServicesAsync() |
|||
{ |
|||
return Task.CompletedTask; |
|||
} |
|||
} |
|||
@ -1,11 +1,13 @@ |
|||
using Volo.Abp.DynamicProxy; |
|||
using System; |
|||
using System.Threading.Tasks; |
|||
using Volo.Abp.DynamicProxy; |
|||
|
|||
namespace Volo.Abp.Autofac.Interception; |
|||
|
|||
public class Autofac_Interception_Test : AbpInterceptionTestBase<AutofacTestModule> |
|||
{ |
|||
protected override void SetAbpApplicationCreationOptions(AbpApplicationCreationOptions options) |
|||
protected override Task<Action<AbpApplicationCreationOptions>> SetAbpApplicationCreationOptionsAsync() |
|||
{ |
|||
options.UseAutofac(); |
|||
return Task.FromResult<Action<AbpApplicationCreationOptions>>(options => options.UseAutofac()); |
|||
} |
|||
} |
|||
|
|||
Loading…
Reference in new issue