feat(wxads): 升级公共组件

This commit is contained in:
Fu Diwei
2022-01-21 09:53:46 +08:00
parent 7205686f71
commit 9b434632d7
10 changed files with 127 additions and 92 deletions

View File

@@ -1,8 +1,11 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>netcoreapp3.1; net6.0</TargetFrameworks>
<LangVersion>9.0</LangVersion>
<TargetFrameworks>net472; netcoreapp3.1; net6.0</TargetFrameworks>
<LangVersion>latest</LangVersion>
<Nullable>enable</Nullable>
<NullableReferenceTypes>true</NullableReferenceTypes>
<IsPackable>false</IsPackable>
</PropertyGroup>
<ItemGroup>

View File

@@ -0,0 +1,57 @@
using System.IO;
using System.Reflection;
using Xunit;
namespace SKIT.FlurlHttpClient.Wechat.Ads.UnitTests
{
public class TestCase_CodeReviewAnalyzer
{
private Assembly SourceAssembly { get; } = Assembly.Load("SKIT.FlurlHttpClient.Wechat.Ads");
[Fact(DisplayName = "代码评审:分析 API 模型命名")]
public void TestApiModelsNaming()
{
CodeStyleUtil.VerifyApiModelsNaming(SourceAssembly, out var ex);
if (ex != null)
throw ex;
Assert.Null(ex);
}
[Fact(DisplayName = "代码评审:分析 API 模型定义")]
public void TestApiModelsDefinition()
{
string workdir = Path.Combine(TestConfigs.ProjectTestDirectory, "ModelSamples");
CodeStyleUtil.VerifyApiModelsDefinition(SourceAssembly, workdir, out var ex);
if (ex != null)
throw ex;
Assert.Null(ex);
}
[Fact(DisplayName = "代码评审:分析 API 接口命名")]
public void TestApiExtensionsNaming()
{
CodeStyleUtil.VerifyApiExtensionsNaming(SourceAssembly, out var ex);
if (ex != null)
throw ex;
Assert.Null(ex);
}
[Fact(DisplayName = "代码评审:分析代码规范")]
public void TestCodeStyle()
{
string workdir = Path.Combine(TestConfigs.ProjectSourceDirectory);
CodeStyleUtil.VerifySourceCodeStyle(workdir, out var ex);
if (ex != null)
throw ex;
Assert.Null(ex);
}
}
}

View File

@@ -1,17 +1,11 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using Xunit;
using Xunit;
namespace SKIT.FlurlHttpClient.Wechat.Ads.UnitTests
{
public class WechatAdsSecurityTests
public class TestCase_HashUtilityTests
{
[Fact(DisplayName = "信息摘要MD5")]
public void Md5HashTest()
[Fact(DisplayName = "测试用例MD5 信息摘要")]
public void TestMD5Hash()
{
string rawData = "spidbff89d5138160943040012345678901234567890uFolxxiZbrZ/PRbyen5uK5D1kgIB2yHyDsfDGxxgeG";

View File

@@ -1,6 +1,4 @@
using System;
namespace SKIT.FlurlHttpClient.Wechat.Ads.UnitTests
namespace SKIT.FlurlHttpClient.Wechat.Ads.UnitTests
{
class TestClients
{

View File

@@ -8,8 +8,9 @@ namespace SKIT.FlurlHttpClient.Wechat.Ads.UnitTests
{
static TestConfigs()
{
// NOTICE: 请在项目根目录下按照 appsettings.json 的格式新建 appsettings.local.json 填入测试参数。
// WARN: 敏感信息请不要提交到 git
// NOTICE: 请在项目根目录下按照 appsettings.json 的格式新建 appsettings.local.json 填入测试参数。
// WARNING: 请在 DEBUG 模式下运行测试用例。
// WARNING: 敏感信息请不要提交到 git
try
{
@@ -17,13 +18,13 @@ namespace SKIT.FlurlHttpClient.Wechat.Ads.UnitTests
using var jdoc = JsonDocument.Parse(stream);
var config = jdoc.RootElement.GetProperty("TestConfig");
WechatAgencyId = config.GetProperty("AgencyId").GetString();
WechatAgencyAppId = config.GetProperty("AgencyAppId").GetString();
WechatAgencyApiKey = config.GetProperty("AgencyApiKey").GetString();
WechatAccessToken = config.GetProperty("AccessToken").GetString();
WechatAgencyId = config.GetProperty("AgencyId").GetString()!;
WechatAgencyAppId = config.GetProperty("AgencyAppId").GetString()!;
WechatAgencyApiKey = config.GetProperty("AgencyApiKey").GetString()!;
WechatAccessToken = config.GetProperty("AccessToken").GetString()!;
ProjectSourceDirectory = jdoc.RootElement.GetProperty("ProjectSourceDirectory").GetString();
ProjectTestDirectory = jdoc.RootElement.GetProperty("ProjectTestDirectory").GetString();
ProjectSourceDirectory = jdoc.RootElement.GetProperty("ProjectSourceDirectory").GetString()!;
ProjectTestDirectory = jdoc.RootElement.GetProperty("ProjectTestDirectory").GetString()!;
}
catch (Exception ex)
{

View File

@@ -1,62 +0,0 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Threading;
using System.Threading.Tasks;
using Xunit;
namespace SKIT.FlurlHttpClient.Wechat.Ads.UnitTests
{
public class WechatAdsDeclarationTests
{
private static readonly Assembly _assembly = Assembly.Load("SKIT.FlurlHttpClient.Wechat.Ads");
[Fact(DisplayName = "验证 API 模型命名")]
public void ApiModelsNamingTest()
{
CodeStyleUtil.VerifyApiModelsNaming(_assembly, out var ex);
if (ex != null)
throw ex;
Assert.Null(ex);
}
[Fact(DisplayName = "验证 API 模型定义")]
public void ApiModelsDefinitionTest()
{
string workdir = Path.Combine(TestConfigs.ProjectTestDirectory, "ModelSamples");
CodeStyleUtil.VerifyApiModelsDefinition(_assembly, workdir, out var ex);
if (ex != null)
throw ex;
Assert.Null(ex);
}
[Fact(DisplayName = "验证 API 接口命名")]
public void ApiExtensionsNamingTest()
{
CodeStyleUtil.VerifyApiExtensionsNaming(_assembly, out var ex);
if (ex != null)
throw ex;
Assert.Null(ex);
}
[Fact(DisplayName = "验证代码规范")]
public void CodeStyleTest()
{
string workdir = Path.Combine(TestConfigs.ProjectSourceDirectory);
CodeStyleUtil.VerifySourceCodeStyle(workdir, out var ex);
if (ex != null)
throw ex;
Assert.Null(ex);
}
}
}

View File

@@ -7,7 +7,7 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="SKIT.FlurlHttpClient.Common" Version="2.1.1" />
<PackageReference Include="SKIT.FlurlHttpClient.Common" Version="2.2.0" />
</ItemGroup>
</Project>