2022-01-20 23:20:03 +08:00
|
|
|
|
using System;
|
|
|
|
|
using System.IO;
|
|
|
|
|
using System.Text.Json;
|
|
|
|
|
|
|
|
|
|
namespace SKIT.FlurlHttpClient.Wechat.TenpayV2.UnitTests
|
|
|
|
|
{
|
|
|
|
|
class TestConfigs
|
|
|
|
|
{
|
|
|
|
|
static TestConfigs()
|
|
|
|
|
{
|
|
|
|
|
// NOTICE: 请在项目根目录下按照 appsettings.json 的格式新建 appsettings.local.json 填入测试参数。
|
|
|
|
|
// WARNING: 请在 DEBUG 模式下运行测试用例。
|
|
|
|
|
// WARNING: 敏感信息请不要提交到 git!
|
|
|
|
|
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
using var stream = File.OpenRead("appsettings.local.json");
|
|
|
|
|
using var jdoc = JsonDocument.Parse(stream);
|
|
|
|
|
|
|
|
|
|
var config = jdoc.RootElement.GetProperty("TestConfig");
|
|
|
|
|
WechatAppId = config.GetProperty("AppId").GetString()!;
|
|
|
|
|
WechatMerchantId = config.GetProperty("MerchantId").GetString()!;
|
|
|
|
|
WechatMerchantSecret = config.GetProperty("MerchantSecret").GetString()!;
|
2022-01-25 13:44:22 +08:00
|
|
|
|
WechatMerchantCertificateBytes = config.GetProperty("MerchantCertificateBase64String").GetBytesFromBase64();
|
2022-01-20 23:20:03 +08:00
|
|
|
|
WechatOpenId = config.GetProperty("OpenId").GetString()!;
|
|
|
|
|
|
2022-02-21 18:27:07 +08:00
|
|
|
|
WorkDirectoryForSdk = jdoc.RootElement.GetProperty("WorkDirectoryForSdk").GetString()!;
|
|
|
|
|
WorkDirectoryForTest = jdoc.RootElement.GetProperty("WorkDirectoryForTest").GetString()!;
|
2022-01-20 23:20:03 +08:00
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
throw new Exception("加载配置文件 appsettings.local.json 失败,请查看 `InnerException` 了解具体失败原因", ex);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static readonly string WechatAppId;
|
|
|
|
|
public static readonly string WechatMerchantId;
|
|
|
|
|
public static readonly string WechatMerchantSecret;
|
2022-01-25 13:44:22 +08:00
|
|
|
|
public static readonly byte[] WechatMerchantCertificateBytes;
|
2022-01-20 23:20:03 +08:00
|
|
|
|
public static readonly string WechatOpenId;
|
|
|
|
|
|
2022-02-21 18:27:07 +08:00
|
|
|
|
public static readonly string WorkDirectoryForSdk;
|
|
|
|
|
public static readonly string WorkDirectoryForTest;
|
2022-01-20 23:20:03 +08:00
|
|
|
|
}
|
|
|
|
|
}
|