DotNetCore.SKIT.FlurlHttpCl.../test/SKIT.FlurlHttpClient.Wechat.Ads.UnitTests/TestConfigs.cs

36 lines
1.4 KiB
C#
Raw Normal View History

using System;
using System.IO;
using System.Text.Json;
namespace SKIT.FlurlHttpClient.Wechat.Ads.UnitTests
{
class TestConfigs
{
static TestConfigs()
{
2021-08-05 17:57:13 +08:00
// NOTICE: 请在项目根目录下按照 appsettings.json 的格式填入测试参数。
// WARN: 敏感信息请不要提交到 git
2021-08-05 17:57:13 +08:00
using var stream = File.OpenRead("appsettings.json");
using var json = JsonDocument.Parse(stream);
var config = json.RootElement.GetProperty("WechatConfig");
WechatAgencyId = config.GetProperty("AgencyId").GetString();
WechatAgencyAppId = config.GetProperty("AgencyAppId").GetString();
WechatAgencyApiKey = config.GetProperty("AgencyApiKey").GetString();
WechatAccessToken = config.GetProperty("AccessToken").GetString();
ProjectSourceDirectory = json.RootElement.GetProperty("ProjectSourceDirectory").GetString();
ProjectTestDirectory = json.RootElement.GetProperty("ProjectTestDirectory").GetString();
}
public static readonly string WechatAgencyId;
public static readonly string WechatAgencyAppId;
public static readonly string WechatAgencyApiKey;
public static readonly string WechatAccessToken;
public static readonly string ProjectSourceDirectory;
public static readonly string ProjectTestDirectory;
}
}