mirror of
https://gitee.com/dotnetchina/OpenAuth.Net.git
synced 2025-09-19 18:22:11 +08:00
同步OpenAuth.Core,单元测试使用WebApi配置文件
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
using Infrastructure;
|
||||
using System;
|
||||
using Infrastructure;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
@@ -52,15 +53,19 @@ namespace OpenAuth.Repository
|
||||
}
|
||||
|
||||
//如果没有租户id,或租户用的是默认的OpenAuthDBContext,则不做任何调整
|
||||
if (string.IsNullOrEmpty(tenantId) || tenantId == "OpenAuthDBContext")
|
||||
if (string.IsNullOrEmpty(tenantId))
|
||||
{
|
||||
return;
|
||||
tenantId = "OpenAuthDBContext";
|
||||
}
|
||||
|
||||
string connect = _configuration.GetConnectionString(tenantId);
|
||||
if (string.IsNullOrEmpty(connect)) return;
|
||||
if (string.IsNullOrEmpty(connect))
|
||||
{
|
||||
throw new Exception($"未能找到租户{tenantId}对应的连接字符串信息");
|
||||
}
|
||||
|
||||
var dbType =_appConfiguration.Value.DbType;
|
||||
//这个地方如果用IOption,在单元测试的时候会获取不到AppSetting的值😅
|
||||
var dbType = _configuration.GetSection("AppSetting")["DbType"];
|
||||
if (dbType == Define.DBTYPE_SQLSERVER)
|
||||
{
|
||||
optionsBuilder.UseSqlServer(connect);
|
||||
|
Reference in New Issue
Block a user