From 21832ca18b560fd7c6cebd6e7e677d770b560f4a Mon Sep 17 00:00:00 2001 From: Fu Diwei Date: Mon, 2 Aug 2021 20:21:45 +0800 Subject: [PATCH] =?UTF-8?q?test(wxapi):=20=E6=96=B0=E5=A2=9E=E9=AA=8C?= =?UTF-8?q?=E8=AF=81=E5=BE=AE=E4=BF=A1=E5=9B=9E=E8=B0=83=E9=80=9A=E7=9F=A5?= =?UTF-8?q?=E4=BA=8B=E4=BB=B6=E7=AD=BE=E5=90=8D=E7=9A=84=E5=8D=95=E5=85=83?= =?UTF-8?q?=E6=B5=8B=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Controllers/WechatNotifyController.cs | 6 +----- .../WechatApiEventDeserializationTests.cs | 7 +++++-- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/samples/SKIT.FlurlHttpClient.Wechat.Api.Sample_Net5/Controllers/WechatNotifyController.cs b/samples/SKIT.FlurlHttpClient.Wechat.Api.Sample_Net5/Controllers/WechatNotifyController.cs index dd9ec531..3f562d46 100644 --- a/samples/SKIT.FlurlHttpClient.Wechat.Api.Sample_Net5/Controllers/WechatNotifyController.cs +++ b/samples/SKIT.FlurlHttpClient.Wechat.Api.Sample_Net5/Controllers/WechatNotifyController.cs @@ -48,11 +48,7 @@ namespace SKIT.FlurlHttpClient.Wechat.Api.Sample_Net5.Controllers // 文档:https://developers.weixin.qq.com/doc/offiaccount/Basic_Information/Access_Overview.html var client = _wechatApiHttpClientFactory.Create(appId); - bool valid = client.VerifyEventSignature( - callbackTimestamp: timestamp, - callbackNonce: nonce, - callbackSignature: signature - ); + bool valid = client.VerifyEventSignatureForEcho(callbackTimestamp: timestamp, callbackNonce: nonce, callbackSignature: signature); if (!valid) { return Content("fail"); diff --git a/test/SKIT.FlurlHttpClient.Wechat.Api.UnitTests/WechatApiEventDeserializationTests.cs b/test/SKIT.FlurlHttpClient.Wechat.Api.UnitTests/WechatApiEventDeserializationTests.cs index 70f49b4e..31d20646 100644 --- a/test/SKIT.FlurlHttpClient.Wechat.Api.UnitTests/WechatApiEventDeserializationTests.cs +++ b/test/SKIT.FlurlHttpClient.Wechat.Api.UnitTests/WechatApiEventDeserializationTests.cs @@ -16,9 +16,12 @@ namespace SKIT.FlurlHttpClient.Wechat.Api.UnitTests string xml = "13488318601234567890123456"; var xDoc = XDocument.Parse(xml); - string @event = xDoc.Root!.Element("MsgType")!.Value.ToUpper(); + string msgType = xDoc.Root!.Element("MsgType")!.Value; - Assert.Equal("TEXT", @event); + Assert.Equal("TEXT", msgType, ignoreCase: true); + + var eventModel = TestClients.Instance.DeserializeEventFromXml(xml); + Assert.Equal("TEXT", eventModel.MessageType, ignoreCase: true); } [Fact(DisplayName = "反序列化 TEXT 事件")]