增加支持Autofac的http单元测试

fix issue #I50DRR
This commit is contained in:
yubaolee
2022-03-31 23:50:04 +08:00
parent 21c1f67d63
commit c19802eb55
6 changed files with 153 additions and 2 deletions

View File

@@ -0,0 +1,18 @@
using Microsoft.AspNetCore.Mvc.Testing;
using Microsoft.Extensions.Hosting;
namespace OpenAuth.WebApi.Test
{
/// <summary>
/// Based upon https://github.com/dotnet/AspNetCore.Docs/tree/master/aspnetcore/test/integration-tests/samples/3.x/IntegrationTestsSample
/// </summary>
/// <typeparam name="TStartup"></typeparam>
public class AutofacWebApplicationFactory<TStartup> : WebApplicationFactory<TStartup> where TStartup : class
{
protected override IHost CreateHost(IHostBuilder builder)
{
builder.UseServiceProviderFactory(new CustomServiceProviderFactory());
return base.CreateHost(builder);
}
}
}