|
|
|
@ -12,6 +12,8 @@ using Microsoft.AspNetCore.TestHost;
|
|
|
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
|
|
|
using Microsoft.Extensions.Hosting;
|
|
|
|
|
|
|
|
|
|
using Serilog;
|
|
|
|
|
|
|
|
|
|
using Xunit;
|
|
|
|
|
using Xunit.DependencyInjection;
|
|
|
|
|
|
|
|
|
@ -65,15 +67,9 @@ namespace HttpClientStudy.UnitTest
|
|
|
|
|
{
|
|
|
|
|
options.PreserveExecutionContext = true;
|
|
|
|
|
})
|
|
|
|
|
.ConfigureTestServices(a =>
|
|
|
|
|
{
|
|
|
|
|
Console.WriteLine("+++++++++++++++++++++++++++++++++");
|
|
|
|
|
|
|
|
|
|
a.BuildServiceProvider().GetRequiredService<IHostApplicationLifetime>().ApplicationStopping.Register(() =>
|
|
|
|
|
{
|
|
|
|
|
Console.WriteLine("=========================");
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
.ConfigureTestServices(services =>
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
})
|
|
|
|
|
.UseStartup<WebApiStartup>()
|
|
|
|
|
;
|
|
|
|
@ -88,7 +84,7 @@ namespace HttpClientStudy.UnitTest
|
|
|
|
|
{
|
|
|
|
|
services.BuildServiceProvider().GetRequiredService<IHostApplicationLifetime>().ApplicationStopping.Register(() =>
|
|
|
|
|
{
|
|
|
|
|
Console.WriteLine("=========================");
|
|
|
|
|
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -96,7 +92,13 @@ namespace HttpClientStudy.UnitTest
|
|
|
|
|
{
|
|
|
|
|
public void ConfigureServices(IServiceCollection services)
|
|
|
|
|
{
|
|
|
|
|
services.AddLogging(lb => lb.AddXunitOutput());
|
|
|
|
|
services.AddLogging(lb => lb.AddXunitOutput());
|
|
|
|
|
services.AddSerilog((services, loggerConfiguration) =>
|
|
|
|
|
{
|
|
|
|
|
loggerConfiguration
|
|
|
|
|
.WriteTo.File("log.txt", outputTemplate: "{Timestamp:yyyy-MM-dd HH:mm:ss.fff zzz} [{Level:u3}] {SourceContext}: {Message:lj}{NewLine}{Exception}")
|
|
|
|
|
.WriteTo.Console();
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void Configure(IApplicationBuilder app)
|
|
|
|
|