mirror of
https://gitee.com/fudiwei/DotNetCore.SKIT.FlurlHttpClient.Wechat.git
synced 2025-09-19 10:08:20 +08:00
60 lines
3.1 KiB
C#
60 lines
3.1 KiB
C#
![]() |
using System;
|
||
|
using System.IO;
|
||
|
using System.Reflection;
|
||
|
using SKIT.FlurlHttpClient.Tools.CodeAnalyzer;
|
||
|
using Xunit;
|
||
|
|
||
|
namespace SKIT.FlurlHttpClient.Wechat.TenpayV3.UnitTests
|
||
|
{
|
||
|
public class CodeAnalyzeTests
|
||
|
{
|
||
|
[Fact(DisplayName = "代码质量分析")]
|
||
|
public void CodeAnalyze()
|
||
|
{
|
||
|
Assert.Null(Record.Exception(() =>
|
||
|
{
|
||
|
var options = new TypeDeclarationAnalyzerOptions()
|
||
|
{
|
||
|
SdkAssembly = Assembly.GetAssembly(typeof(WechatTenpayClient))!,
|
||
|
SdkRequestModelDeclarationNamespace = "SKIT.FlurlHttpClient.Wechat.TenpayV3.Models",
|
||
|
SdkResponseModelDeclarationNamespace = "SKIT.FlurlHttpClient.Wechat.TenpayV3.Models",
|
||
|
SdkExecutingExtensionDeclarationNamespace = "SKIT.FlurlHttpClient.Wechat.TenpayV3",
|
||
|
SdkWebhookEventDeclarationNamespace = "SKIT.FlurlHttpClient.Wechat.TenpayV3.Events",
|
||
|
ThrowOnNotFoundRequestModelTypes = true,
|
||
|
ThrowOnNotFoundResponseModelTypes = true,
|
||
|
ThrowOnNotFoundExecutingExtensionTypes = true,
|
||
|
ThrowOnNotFoundWebhookEventTypes = true
|
||
|
};
|
||
|
new TypeDeclarationAnalyzer(options).AssertNoIssues();
|
||
|
}));
|
||
|
|
||
|
Assert.Null(Record.Exception(() =>
|
||
|
{
|
||
|
string workdir = Environment.CurrentDirectory;
|
||
|
string projdir = Path.Combine(workdir, "../../../../../");
|
||
|
|
||
|
var options = new SourceFileAnalyzerOptions()
|
||
|
{
|
||
|
SdkAssembly = Assembly.GetAssembly(typeof(WechatTenpayClient))!,
|
||
|
SdkRequestModelDeclarationNamespace = "SKIT.FlurlHttpClient.Wechat.TenpayV3.Models",
|
||
|
SdkResponseModelDeclarationNamespace = "SKIT.FlurlHttpClient.Wechat.TenpayV3.Models",
|
||
|
SdkWebhookEventDeclarationNamespace = "SKIT.FlurlHttpClient.Wechat.TenpayV3.Events",
|
||
|
ProjectSourceRootDirectory = Path.Combine(projdir, "./src/SKIT.FlurlHttpClient.Wechat.TenpayV3/"),
|
||
|
ProjectTestRootDirectory = Path.Combine(projdir, "./test/SKIT.FlurlHttpClient.Wechat.TenpayV3.UnitTests/"),
|
||
|
ThrowOnNotFoundRequestModelClassCodeFiles = true,
|
||
|
ThrowOnNotFoundResponseModelClassCodeFiles = true,
|
||
|
ThrowOnNotFoundExecutingExtensionClassCodeFiles = true,
|
||
|
ThrowOnNotFoundWebhookEventClassCodeFiles = true,
|
||
|
ThrowOnNotFoundRequestModelSerializationSampleFiles = true,
|
||
|
ThrowOnNotFoundResponseModelSerializationSampleFiles = true,
|
||
|
ThrowOnNotFoundWebhookEventSerializationSampleFiles = true
|
||
|
};
|
||
|
new SourceFileAnalyzer(options)
|
||
|
.SetFileScanner(SourceFileContentKinds.WebhookEventClassCode, (directory) => directory.GetAllFiles("*.cs"))
|
||
|
.SetFileScanner(SourceFileContentKinds.WebhookEventSerializationSample, (directory) => directory.GetAllFiles("*.json"))
|
||
|
.AssertNoIssues();
|
||
|
}));
|
||
|
}
|
||
|
}
|
||
|
}
|