mirror of
https://gitee.com/dotnetchina/OpenAuth.Net.git
synced 2025-09-20 10:37:55 +08:00
增加支持Autofac的http单元测试
fix issue #I50DRR
This commit is contained in:
18
OpenAuth.WebApi/Test/AutofacWebApplicationFactory.cs
Normal file
18
OpenAuth.WebApi/Test/AutofacWebApplicationFactory.cs
Normal 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);
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user