using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using System.Xml.Linq;
using Xunit;
namespace SKIT.FlurlHttpClient.Wechat.Api.UnitTests
{
public class WechatApiEventVerificationTests
{
[Fact(DisplayName = "验签并解密回调数据")]
public void GetEventMessageTypeTest()
{
string callbacMsgSig = "477715d11cdb4164915debcba66cb864d751f3e6";
string callbacTimeStamp = "1409659813";
string callbacNonce = "1372623149";
string callbackXml = "";
var options = new WechatApiClientOptions()
{
AppId = "wx5823bf96d3bd56c7",
PushEncodingAESKey = "jWmYm7qr5nMoAUwZRjGtBxmz3KA1tkAj3ykkR6q2B2C",
PushToken = "QDG6eK"
};
var client = new WechatApiClient(options);
var eventModel = client.DeserializeEventFromXml(callbackXml, safety: true);
Assert.True(client.VerifyEventSignatureFromXml(callbacTimeStamp, callbacNonce, callbackXml, callbacMsgSig));
Assert.Equal("text", eventModel.MessageType, ignoreCase: true);
Assert.Equal("hello", eventModel.Content);
Assert.Equal("wx5823bf96d3bd56c7", eventModel.ToUserName);
Assert.Equal("mycreate", eventModel.FromUserName);
}
}
}