|
|
|
@ -1,15 +1,4 @@
|
|
|
|
|
//using System;
|
|
|
|
|
//using System.Collections.Generic;
|
|
|
|
|
//using System.Linq;
|
|
|
|
|
//using System.Text;
|
|
|
|
|
//using System.Threading.Tasks;
|
|
|
|
|
|
|
|
|
|
//using Microsoft.AspNetCore.Builder;
|
|
|
|
|
//using Microsoft.AspNetCore.Hosting;
|
|
|
|
|
//using Microsoft.AspNetCore.TestHost;
|
|
|
|
|
//using Microsoft.Extensions.Configuration;
|
|
|
|
|
//using Microsoft.Extensions.DependencyInjection;
|
|
|
|
|
//using Microsoft.Extensions.Hosting;
|
|
|
|
|
using System.Diagnostics;
|
|
|
|
|
|
|
|
|
|
using Microsoft.AspNetCore.Builder;
|
|
|
|
|
using Microsoft.AspNetCore.Hosting;
|
|
|
|
@ -19,6 +8,7 @@ using Microsoft.Extensions.DependencyInjection;
|
|
|
|
|
using Microsoft.Extensions.Hosting;
|
|
|
|
|
|
|
|
|
|
using Xunit;
|
|
|
|
|
using Xunit.DependencyInjection;
|
|
|
|
|
using Xunit.DependencyInjection.AspNetCoreTesting;
|
|
|
|
|
using Xunit.DependencyInjection.Logging;
|
|
|
|
|
|
|
|
|
@ -44,17 +34,17 @@ namespace HttpClientStudy.UnitTest
|
|
|
|
|
/// <param name="hostBuilder"></param>
|
|
|
|
|
public void ConfigureHost(IHostBuilder hostBuilder)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
hostBuilder
|
|
|
|
|
.ConfigureWebHost
|
|
|
|
|
(webHostBuilder => webHostBuilder
|
|
|
|
|
.UseTestServerAndAddDefaultHttpClient()
|
|
|
|
|
.UseStartup<WebApiStartup>()
|
|
|
|
|
);
|
|
|
|
|
//主机配置
|
|
|
|
|
.ConfigureHostConfiguration(builder =>
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
})
|
|
|
|
|
//应用配置
|
|
|
|
|
.ConfigureAppConfiguration((context, builder) =>
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
//hostBuilder
|
|
|
|
|
// .ConfigureHostConfiguration(builder => { })
|
|
|
|
|
// .ConfigureAppConfiguration((context, builder) => { });
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
hostBuilder.ConfigureWebHost(webHostBuilder =>
|
|
|
|
|
{
|
|
|
|
@ -83,7 +73,7 @@ namespace HttpClientStudy.UnitTest
|
|
|
|
|
/// <param name="services"></param>
|
|
|
|
|
public void ConfigureServices(IServiceCollection services,HostBuilderContext context)
|
|
|
|
|
{
|
|
|
|
|
//services.AddTransient<IDependency, DependencyClass>();
|
|
|
|
|
Debugger.Log(1,"DI","ConfigureServices");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private class WebApiStartup
|
|
|
|
|