test: 优化 CodeStyle 测试流程

This commit is contained in:
Fu Diwei
2021-11-10 12:59:08 +08:00
parent 11ce0773a1
commit c8ee389674
20 changed files with 334 additions and 218 deletions

View File

@@ -8,20 +8,27 @@ namespace SKIT.FlurlHttpClient.Wechat.Api.UnitTests
{
static TestConfigs()
{
// NOTICE: 请在项目根目录下按照 appsettings.json 的格式填入测试参数。
// NOTICE: 请在项目根目录下按照 appsettings.json 的格式新建 appsettings.local.json 填入测试参数。
// WARN: 敏感信息请不要提交到 git
using var stream = File.OpenRead("appsettings.json");
using var json = JsonDocument.Parse(stream);
try
{
using var stream = File.OpenRead("appsettings.local.json");
using var jdoc = JsonDocument.Parse(stream);
var config = json.RootElement.GetProperty("WechatConfig");
WechatAppId = config.GetProperty("AppId").GetString();
WechatAppSecret = config.GetProperty("AppSecret").GetString();
WechatAccessToken = config.GetProperty("AccessToken").GetString();
WechatOpenId = config.GetProperty("OpenId").GetString();
var config = jdoc.RootElement.GetProperty("WechatConfig");
WechatAppId = config.GetProperty("AppId").GetString();
WechatAppSecret = config.GetProperty("AppSecret").GetString();
WechatAccessToken = config.GetProperty("AccessToken").GetString();
WechatOpenId = config.GetProperty("OpenId").GetString();
ProjectSourceDirectory = json.RootElement.GetProperty("ProjectSourceDirectory").GetString();
ProjectTestDirectory = json.RootElement.GetProperty("ProjectTestDirectory").GetString();
ProjectSourceDirectory = jdoc.RootElement.GetProperty("ProjectSourceDirectory").GetString();
ProjectTestDirectory = jdoc.RootElement.GetProperty("ProjectTestDirectory").GetString();
}
catch (Exception ex)
{
throw new Exception("加载配置文件 appsettings.local.json 失败", ex);
}
}
public static readonly string WechatAppId;