2021-05-10 15:30:00 +08:00
|
|
|
|
using System;
|
|
|
|
|
using System.IO;
|
|
|
|
|
using System.Text.Json;
|
|
|
|
|
|
|
|
|
|
namespace SKIT.FlurlHttpClient.Wechat.TenpayV3.UnitTests
|
|
|
|
|
{
|
2022-01-21 14:30:17 +08:00
|
|
|
|
internal class TestConfigs
|
2021-05-10 15:30:00 +08:00
|
|
|
|
{
|
|
|
|
|
static TestConfigs()
|
|
|
|
|
{
|
2021-11-10 12:59:08 +08:00
|
|
|
|
// NOTICE: 请在项目根目录下按照 appsettings.json 的格式新建 appsettings.local.json 填入测试参数。
|
2021-05-10 15:30:00 +08:00
|
|
|
|
// WARN: 敏感信息请不要提交到 git!
|
|
|
|
|
|
2021-11-10 12:59:08 +08:00
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
using var stream = File.OpenRead("appsettings.local.json");
|
|
|
|
|
using var jdoc = JsonDocument.Parse(stream);
|
2021-06-07 11:18:27 +08:00
|
|
|
|
|
2021-11-29 11:53:38 +08:00
|
|
|
|
var config = jdoc.RootElement.GetProperty("TestConfig");
|
2022-01-21 13:10:56 +08:00
|
|
|
|
WechatMerchantId = config.GetProperty("MerchantId").GetString()!;
|
|
|
|
|
WechatMerchantSecret = config.GetProperty("MerchantSecret").GetString()!;
|
|
|
|
|
WechatMerchantCertSerialNumber = config.GetProperty("MerchantCertSerialNumber").GetString()!;
|
|
|
|
|
WechatMerchantCertPrivateKey = config.GetProperty("MerchantCertPrivateKey").GetString()!;
|
|
|
|
|
WechatAppId = config.GetProperty("AppId").GetString()!;
|
|
|
|
|
WechatOpenId = config.GetProperty("OpenId").GetString()!;
|
2021-06-07 11:18:27 +08:00
|
|
|
|
|
2022-02-21 18:27:07 +08:00
|
|
|
|
WorkDirectoryForSdk = jdoc.RootElement.GetProperty("WorkDirectoryForSdk").GetString()!;
|
|
|
|
|
WorkDirectoryForTest = jdoc.RootElement.GetProperty("WorkDirectoryForTest").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-05-10 15:30:00 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static readonly string WechatMerchantId;
|
|
|
|
|
public static readonly string WechatMerchantSecret;
|
|
|
|
|
public static readonly string WechatMerchantCertSerialNumber;
|
|
|
|
|
public static readonly string WechatMerchantCertPrivateKey;
|
2022-01-21 13:10:56 +08:00
|
|
|
|
public static readonly string WechatAppId;
|
2021-05-10 15:30:00 +08:00
|
|
|
|
public static readonly string WechatOpenId;
|
2021-06-07 11:18:27 +08:00
|
|
|
|
|
2022-02-21 18:27:07 +08:00
|
|
|
|
public static readonly string WorkDirectoryForSdk;
|
|
|
|
|
public static readonly string WorkDirectoryForTest;
|
2021-05-10 15:30:00 +08:00
|
|
|
|
}
|
|
|
|
|
}
|