From 45e90ca35348dd86105e2f1bafa14b7a9543a62c Mon Sep 17 00:00:00 2001 From: Fu Diwei Date: Thu, 26 Aug 2021 16:48:15 +0800 Subject: [PATCH] =?UTF-8?q?test(wxapi):=20=E9=80=82=E9=85=8D=E6=96=B0?= =?UTF-8?q?=E7=9A=84=E6=8E=A5=E5=8F=A3=E6=A8=A1=E5=9E=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../CgibinMessageSubscribeSendRequest.json | 21 +++++++++++++++++++ .../CgibinMessageSubscribeSendResponse.json | 4 ++++ .../CodeStyleUtil.cs | 19 ++++++++++------- 3 files changed, 36 insertions(+), 8 deletions(-) create mode 100644 test/SKIT.FlurlHttpClient.Wechat.Api.UnitTests/ModelSamples/CgibinMessageSubscribe/CgibinMessageSubscribeSendRequest.json create mode 100644 test/SKIT.FlurlHttpClient.Wechat.Api.UnitTests/ModelSamples/CgibinMessageSubscribe/CgibinMessageSubscribeSendResponse.json diff --git a/test/SKIT.FlurlHttpClient.Wechat.Api.UnitTests/ModelSamples/CgibinMessageSubscribe/CgibinMessageSubscribeSendRequest.json b/test/SKIT.FlurlHttpClient.Wechat.Api.UnitTests/ModelSamples/CgibinMessageSubscribe/CgibinMessageSubscribeSendRequest.json new file mode 100644 index 00000000..463a6d6b --- /dev/null +++ b/test/SKIT.FlurlHttpClient.Wechat.Api.UnitTests/ModelSamples/CgibinMessageSubscribe/CgibinMessageSubscribeSendRequest.json @@ -0,0 +1,21 @@ +{ + "touser": "OPENID", + "template_id": "TEMPLATE_ID", + "page": "index", + "miniprogram_state": "developer", + "lang": "zh_CN", + "data": { + "number01": { + "value": "339208499" + }, + "date01": { + "value": "2015年01月05日" + }, + "site01": { + "value": "TIT创意园" + }, + "site02": { + "value": "广州市新港中路397号" + } + } +} \ No newline at end of file diff --git a/test/SKIT.FlurlHttpClient.Wechat.Api.UnitTests/ModelSamples/CgibinMessageSubscribe/CgibinMessageSubscribeSendResponse.json b/test/SKIT.FlurlHttpClient.Wechat.Api.UnitTests/ModelSamples/CgibinMessageSubscribe/CgibinMessageSubscribeSendResponse.json new file mode 100644 index 00000000..f752befe --- /dev/null +++ b/test/SKIT.FlurlHttpClient.Wechat.Api.UnitTests/ModelSamples/CgibinMessageSubscribe/CgibinMessageSubscribeSendResponse.json @@ -0,0 +1,4 @@ +{ + "errcode": 0, + "errmsg": "ok" +} \ No newline at end of file diff --git a/test/SKIT.FlurlHttpClient.Wechat.TestTools/CodeStyleUtil.cs b/test/SKIT.FlurlHttpClient.Wechat.TestTools/CodeStyleUtil.cs index 6051f1d0..27aab4fe 100644 --- a/test/SKIT.FlurlHttpClient.Wechat.TestTools/CodeStyleUtil.cs +++ b/test/SKIT.FlurlHttpClient.Wechat.TestTools/CodeStyleUtil.cs @@ -490,16 +490,19 @@ namespace SKIT.FlurlHttpClient.Wechat // 如果是 GET 请求,检查是否包含 JSON 序列化字段 if ("GET".Equals(expectedRequestMethod, StringComparison.OrdinalIgnoreCase)) { - if (new Regex("\\[Newtonsoft.Json.JsonProperty\\(\"[a-zA-Z0-9_]*\"\\)\\]").IsMatch(reqCodeSourceCode)) + if (!reqCodeSourceCode.Contains("/* @codestyle-disable") || !reqCodeSourceCode.Contains("no-jsonable-property-in-get")) { - lstError.Add(new Exception($"源代码 \"{reqCodeFileName}\" 下文档代码有误,请求模型为简单请求、不应包含可 JSON 序列化字段。")); - return false; - } + if (new Regex("\\[Newtonsoft.Json.JsonProperty\\(\"[a-zA-Z0-9_]*\"\\)\\]").IsMatch(reqCodeSourceCode)) + { + lstError.Add(new Exception($"源代码 \"{reqCodeFileName}\" 下文档代码有误,请求模型为简单请求、不应包含可 JSON 序列化字段。")); + return false; + } - if (new Regex("\\[System.Text.Json.Serialization.JsonPropertyName\\(\"[a-zA-Z0-9_]*\"\\)\\]").IsMatch(reqCodeSourceCode)) - { - lstError.Add(new Exception($"源代码 \"{reqCodeFileName}\" 下文档代码有误,请求模型为简单请求、不应包含可 JSON 序列化字段。")); - return false; + if (new Regex("\\[System.Text.Json.Serialization.JsonPropertyName\\(\"[a-zA-Z0-9_]*\"\\)\\]").IsMatch(reqCodeSourceCode)) + { + lstError.Add(new Exception($"源代码 \"{reqCodeFileName}\" 下文档代码有误,请求模型为简单请求、不应包含可 JSON 序列化字段。")); + return false; + } } }