mirror of
https://gitee.com/fudiwei/DotNetCore.SKIT.FlurlHttpClient.Wechat.git
synced 2026-01-18 19:51:36 +08:00
test: 设计代码分析工具,以规避拼写错误导致的 API 定义问题
This commit is contained in:
@@ -11,12 +11,8 @@
|
||||
<Content Include="appsettings.local.json">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</Content>
|
||||
<Content Include="ModelSamples/**/*.json">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</Content>
|
||||
<Content Include="EventSamples/**/*.json">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</Content>
|
||||
<Content Include="ModelSamples/**/*.json" />
|
||||
<Content Include="EventSamples/**/*.json" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
||||
@@ -13,6 +13,7 @@ namespace SKIT.FlurlHttpClient.Wechat.TenpayV3.UnitTests
|
||||
|
||||
using var stream = File.OpenRead("appsettings.local.json");
|
||||
using var json = JsonDocument.Parse(stream);
|
||||
|
||||
var config = json.RootElement.GetProperty("WechatConfig");
|
||||
WechatAppId = config.GetProperty("AppId").GetString();
|
||||
WechatMerchantId = config.GetProperty("MerchantId").GetString();
|
||||
@@ -20,6 +21,9 @@ namespace SKIT.FlurlHttpClient.Wechat.TenpayV3.UnitTests
|
||||
WechatMerchantCertSerialNumber = config.GetProperty("MerchantCertSerialNumber").GetString();
|
||||
WechatMerchantCertPrivateKey = config.GetProperty("MerchantCertPrivateKey").GetString();
|
||||
WechatOpenId = config.GetProperty("OpenId").GetString();
|
||||
|
||||
ProjectSourceDirectory = json.RootElement.GetProperty("ProjectSourceDirectory").GetString();
|
||||
ProjectTestDirectory = json.RootElement.GetProperty("ProjectTestDirectory").GetString();
|
||||
}
|
||||
|
||||
public static readonly string WechatAppId;
|
||||
@@ -28,5 +32,8 @@ namespace SKIT.FlurlHttpClient.Wechat.TenpayV3.UnitTests
|
||||
public static readonly string WechatMerchantCertSerialNumber;
|
||||
public static readonly string WechatMerchantCertPrivateKey;
|
||||
public static readonly string WechatOpenId;
|
||||
|
||||
public static readonly string ProjectSourceDirectory;
|
||||
public static readonly string ProjectTestDirectory;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,7 +27,7 @@ namespace SKIT.FlurlHttpClient.Wechat.TenpayV3.UnitTests
|
||||
[Fact(DisplayName = "验证 API 模型定义")]
|
||||
public void ApiModelsDefinitionTest()
|
||||
{
|
||||
string workdir = Path.Combine(Environment.CurrentDirectory, "ModelSamples");
|
||||
string workdir = Path.Combine(TestConfigs.ProjectTestDirectory, "ModelSamples");
|
||||
Assert.True(Directory.Exists(workdir));
|
||||
|
||||
TestAssertUtil.VerifyApiModelsDefinition(_assembly, workdir, out var ex);
|
||||
@@ -41,7 +41,7 @@ namespace SKIT.FlurlHttpClient.Wechat.TenpayV3.UnitTests
|
||||
[Fact(DisplayName = "验证 API 事件定义")]
|
||||
public void ApiEventsDefinitionTest()
|
||||
{
|
||||
string workdir = Path.Combine(Environment.CurrentDirectory, "EventSamples");
|
||||
string workdir = Path.Combine(TestConfigs.ProjectTestDirectory, "EventSamples");
|
||||
Assert.True(Directory.Exists(workdir));
|
||||
|
||||
TestAssertUtil.VerifyApiEventsDefinition(_assembly, workdir, out var ex);
|
||||
@@ -62,5 +62,19 @@ namespace SKIT.FlurlHttpClient.Wechat.TenpayV3.UnitTests
|
||||
|
||||
Assert.Null(ex);
|
||||
}
|
||||
|
||||
[Fact(DisplayName = "验证 API 接口文档注释")]
|
||||
public void ApiExtensionsDocumentationTest()
|
||||
{
|
||||
string workdir = Path.Combine(TestConfigs.ProjectSourceDirectory, "Extensions");
|
||||
Assert.True(Directory.Exists(workdir));
|
||||
|
||||
TestAssertUtil.VerifyApiExtensionsSourceCodeStyle(workdir, out var ex);
|
||||
|
||||
if (ex != null)
|
||||
throw ex;
|
||||
|
||||
Assert.Null(ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,5 +6,7 @@
|
||||
"MerchantCertSerialNumber": "请在此填写用于测试的微信商户 API 证书序列号",
|
||||
"MerchantCertPrivateKey": "请在此填写用于测试的微信商户 API 私钥(字符串格式)",
|
||||
"OpenId": "请在此填写用于测试的微信用户唯一标识"
|
||||
}
|
||||
},
|
||||
"ProjectSourceDirectory": "请输入当前 SDK 项目所在的目录完整路径,如 C:\\Project\\src\\SKIT.FlurlHttpClient.Wechat.TenpayV3\\",
|
||||
"ProjectTestDirectory": "请输入当前测试项目所在的目录完整路径,如 C:\\Project\\test\\SKIT.FlurlHttpClient.Wechat.TenpayV3.UnitTests\\"
|
||||
}
|
||||
Reference in New Issue
Block a user