using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.DependencyInjection;
using SJZY.Track.Api;
using SJZY.Track.Application;
using SJZY.Track.Infrastructure;
using Volo.Abp;
using Volo.Abp.AspNetCore.TestBase;
using Volo.Abp.Authorization;
using Volo.Abp.Autofac;
using Volo.Abp.Data;
using Volo.Abp.Http.Client;
using Volo.Abp.Modularity;
using Volo.Abp.Threading;
[assembly: HostingStartup(typeof(SJZY.Expand.ABP.Core.HostingStartup))]
namespace SJZY.Track.Test;
[DependsOn(
typeof(AbpAspNetCoreTestBaseModule),
typeof(AbpAutofacModule),
typeof(AbpAuthorizationModule),
typeof(SjzyTrackInfrastructureModule),
typeof(SjzyTrackApplicationModule),
typeof(SjzyTrackApiModule),
typeof(AbpHttpClientModule) //添加abp的http代理模块
)]
[assembly: HostingStartup(typeof(Expand.ABP.Core.HostingStartup))]
public class TestModule : AbpModule
{
public override void ConfigureServices(ServiceConfigurationContext context)
{
context.Services.AddAlwaysAllowAuthorization();
//添加内网服务
//context.Services.AddHttpClientProxies(typeof(LoggerCenterHttpApiModule).Assembly, "LoggerCenter", false);
}
public override void OnApplicationInitialization(ApplicationInitializationContext context)
{
SeedTestData(context);
}
public override void OnApplicationShutdown(ApplicationShutdownContext context)
{
//根据业务场景决定,是否需要删除测试数据
}
///
/// 生成种子测试数据
///
///
private static void SeedTestData(ApplicationInitializationContext context)
{
AsyncHelper.RunSync(async () =>
{
using (var scope = context.ServiceProvider.CreateScope())
{
await scope.ServiceProvider
.GetRequiredService()
.SeedAsync();
}
});
}
}