2022-11-21 11:30:38 +08:00
|
|
|
|
using System;
|
2021-10-07 21:19:24 +08:00
|
|
|
|
using System.IO;
|
|
|
|
|
using System.Text.Json;
|
|
|
|
|
|
|
|
|
|
namespace SKIT.FlurlHttpClient.Wechat.OpenAI.UnitTests
|
|
|
|
|
{
|
2022-01-21 10:09:50 +08:00
|
|
|
|
internal class TestConfigs
|
2021-10-07 21:19:24 +08:00
|
|
|
|
{
|
|
|
|
|
static TestConfigs()
|
|
|
|
|
{
|
2022-01-21 10:09:50 +08:00
|
|
|
|
// NOTICE: 请在项目根目录下按照 appsettings.json 的格式新建 appsettings.local.json 填入测试参数。
|
2022-05-06 20:29:27 +08:00
|
|
|
|
// WARNING: 请在 DEBUG 模式下运行测试用例。
|
2022-01-21 10:09:50 +08:00
|
|
|
|
// WARNING: 敏感信息请不要提交到 git!
|
2021-10-07 21:19:24 +08:00
|
|
|
|
|
2021-11-10 12:59:08 +08:00
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
using var stream = File.OpenRead("appsettings.local.json");
|
|
|
|
|
using var jdoc = JsonDocument.Parse(stream);
|
2021-10-07 21:19:24 +08:00
|
|
|
|
|
2024-01-29 23:12:04 +08:00
|
|
|
|
var config = jdoc.RootElement.GetProperty("TestConfigs");
|
2022-01-21 10:09:50 +08:00
|
|
|
|
WechatAppId = config.GetProperty("AppId").GetString()!;
|
|
|
|
|
WechatToken = config.GetProperty("Token").GetString()!;
|
|
|
|
|
WechatEncodingAESKey = config.GetProperty("EncodingAESKey").GetString()!;
|
|
|
|
|
WechatAccessToken = config.GetProperty("AccessToken").GetString()!;
|
2021-11-10 12:59:08 +08:00
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
2021-11-29 11:53:38 +08:00
|
|
|
|
throw new Exception("加载配置文件 appsettings.local.json 失败,请查看 `InnerException` 了解具体失败原因", ex);
|
2021-11-10 12:59:08 +08:00
|
|
|
|
}
|
2021-10-07 21:19:24 +08:00
|
|
|
|
}
|
|
|
|
|
|
2021-10-11 18:34:21 +08:00
|
|
|
|
public static readonly string WechatAppId;
|
|
|
|
|
public static readonly string WechatToken;
|
|
|
|
|
public static readonly string WechatEncodingAESKey;
|
2021-10-07 21:19:24 +08:00
|
|
|
|
public static readonly string WechatAccessToken;
|
|
|
|
|
}
|
|
|
|
|
}
|