增加支持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

@@ -1,4 +1,4 @@
using System;
using System;
using System.IO;
using System.Linq;
using Autofac.Extensions.DependencyInjection;
@@ -27,7 +27,11 @@ namespace OpenAuth.App.Test
serviceCollection.AddOptions();
//读取OpenAuth.WebApi的配置文件用于单元测试
var path = AppContext.BaseDirectory;
int pos = path.LastIndexOf("OpenAuth.");
int pos = path.IndexOf("OpenAuth.App");
if (pos == -1) //如果测试入口是OpenAuth.WebApi
{
pos = path.IndexOf("OpenAuth.WebApi");
}
var basepath = Path.Combine(path.Substring(0,pos) ,"OpenAuth.WebApi");
IConfiguration config = new ConfigurationBuilder()
.SetBasePath(basepath)