mirror of
https://gitee.com/fudiwei/DotNetCore.SKIT.FlurlHttpClient.Wechat.git
synced 2025-09-21 02:58:06 +08:00
feat(openai): 升级公共组件
This commit is contained in:
@@ -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>
|
||||
|
@@ -0,0 +1,69 @@
|
||||
using System.IO;
|
||||
using System.Reflection;
|
||||
using Xunit;
|
||||
|
||||
namespace SKIT.FlurlHttpClient.Wechat.OpenAI.UnitTests
|
||||
{
|
||||
public class TestCase_CodeReviewAnalyzer
|
||||
{
|
||||
private Assembly SourceAssembly { get; } = Assembly.Load("SKIT.FlurlHttpClient.Wechat.OpenAI");
|
||||
|
||||
[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 TestApiEventsDefinition()
|
||||
{
|
||||
string workdir = Path.Combine(TestConfigs.ProjectTestDirectory, "EventSamples");
|
||||
CodeStyleUtil.VerifyApiEventsDefinition(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);
|
||||
}
|
||||
}
|
||||
}
|
@@ -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.OpenAI.UnitTests
|
||||
{
|
||||
public class WechatOpenAIJWTTests
|
||||
public class TestCase_JWTUtilityTests
|
||||
{
|
||||
[Fact(DisplayName = "JWT 编码(HS256)")]
|
||||
public void JWTEncodeWithHS256Test()
|
||||
[Fact(DisplayName = "测试用例:JWT HS256 编码")]
|
||||
public void TestJWTEncodeWithHS256()
|
||||
{
|
||||
object payload = new
|
||||
{
|
@@ -1,13 +1,11 @@
|
||||
using System;
|
||||
|
||||
namespace SKIT.FlurlHttpClient.Wechat.OpenAI.UnitTests
|
||||
namespace SKIT.FlurlHttpClient.Wechat.OpenAI.UnitTests
|
||||
{
|
||||
class TestClients
|
||||
internal class TestClients
|
||||
{
|
||||
static TestClients()
|
||||
{
|
||||
InstanceForPlatform = new WechatOpenAIPlatformClient(new WechatOpenAIPlatformClientOptions()
|
||||
{
|
||||
{
|
||||
AppId = TestConfigs.WechatAppId,
|
||||
Token = TestConfigs.WechatToken,
|
||||
EncodingAESKey = TestConfigs.WechatEncodingAESKey
|
||||
|
@@ -4,12 +4,13 @@ using System.Text.Json;
|
||||
|
||||
namespace SKIT.FlurlHttpClient.Wechat.OpenAI.UnitTests
|
||||
{
|
||||
class TestConfigs
|
||||
internal class TestConfigs
|
||||
{
|
||||
static TestConfigs()
|
||||
{
|
||||
// NOTICE: 请在项目根目录下按照 appsettings.json 的格式新建 appsettings.local.json 填入测试参数。
|
||||
// WARN: 敏感信息请不要提交到 git!
|
||||
// NOTICE: 请在项目根目录下按照 appsettings.json 的格式新建 appsettings.local.json 填入测试参数。
|
||||
// WARNING: 请在 DEBUG 模式下运行测试用例。
|
||||
// WARNING: 敏感信息请不要提交到 git!
|
||||
|
||||
try
|
||||
{
|
||||
@@ -17,15 +18,15 @@ namespace SKIT.FlurlHttpClient.Wechat.OpenAI.UnitTests
|
||||
using var jdoc = JsonDocument.Parse(stream);
|
||||
|
||||
var config = jdoc.RootElement.GetProperty("TestConfig");
|
||||
WechatClientId = config.GetProperty("ClientId").GetString();
|
||||
WechatClientKey = config.GetProperty("ClientKey").GetString();
|
||||
WechatAppId = config.GetProperty("AppId").GetString();
|
||||
WechatToken = config.GetProperty("Token").GetString();
|
||||
WechatEncodingAESKey = config.GetProperty("EncodingAESKey").GetString();
|
||||
WechatAccessToken = config.GetProperty("AccessToken").GetString();
|
||||
WechatClientId = config.GetProperty("ClientId").GetString()!;
|
||||
WechatClientKey = config.GetProperty("ClientKey").GetString()!;
|
||||
WechatAppId = config.GetProperty("AppId").GetString()!;
|
||||
WechatToken = config.GetProperty("Token").GetString()!;
|
||||
WechatEncodingAESKey = config.GetProperty("EncodingAESKey").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)
|
||||
{
|
||||
|
@@ -1,74 +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.OpenAI.UnitTests
|
||||
{
|
||||
public class WechatOpenAIDeclarationTests
|
||||
{
|
||||
private static readonly Assembly _assembly = Assembly.Load("SKIT.FlurlHttpClient.Wechat.OpenAI");
|
||||
|
||||
[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 ApiEventsDefinitionTest()
|
||||
{
|
||||
string workdir = Path.Combine(TestConfigs.ProjectTestDirectory, "EventSamples");
|
||||
CodeStyleUtil.VerifyApiEventsDefinition(_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);
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user