You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
42 lines
1.4 KiB
C#
42 lines
1.4 KiB
C#
using Microsoft.Extensions.Configuration;
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
using Microsoft.Extensions.Hosting;
|
|
using Microsoft.Extensions.Logging;
|
|
|
|
namespace NPin.Test;
|
|
|
|
public class NPinTestBase : AbpTestBaseWithServiceProvider
|
|
{
|
|
public ILogger Logger { get; private set; }
|
|
|
|
protected IServiceScope TestServiceScope { get; }
|
|
|
|
public NPinTestBase()
|
|
{
|
|
IHost host = Host.CreateDefaultBuilder()
|
|
.UseAutofac()
|
|
.ConfigureServices((host, service) =>
|
|
{
|
|
ConfigureServices(host, service);
|
|
service.AddLogging(builder => builder.ClearProviders().AddConsole().AddDebug());
|
|
service.AddApplicationAsync<NPinTestModule>().Wait();
|
|
})
|
|
.ConfigureAppConfiguration(ConfigureAppConfiguration)
|
|
.Build();
|
|
|
|
ServiceProvider = host.Services;
|
|
TestServiceScope = ServiceProvider.CreateScope();
|
|
Logger = (ILogger)ServiceProvider.GetRequiredService(typeof(ILogger<>).MakeGenericType(GetType()));
|
|
|
|
host.InitializeAsync().Wait();
|
|
}
|
|
|
|
public virtual void ConfigureServices(HostBuilderContext host, IServiceCollection service)
|
|
{
|
|
}
|
|
|
|
protected virtual void ConfigureAppConfiguration(IConfigurationBuilder configurationBuilder)
|
|
{
|
|
configurationBuilder.AddJsonFile("appsettings.json");
|
|
}
|
|
} |