test(wxapi): 补充服务器推送单元测试

This commit is contained in:
Fu Diwei
2021-08-02 12:43:01 +08:00
parent ce29cf383d
commit cb4f12b536
2 changed files with 15 additions and 3 deletions

View File

@@ -3,12 +3,24 @@ 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 WechatApiEventDeserializationTests
{
[Fact(DisplayName = "获取事件消息类型")]
public void GetEventMessageTypeTest()
{
string xml = "<xml><ToUserName><![CDATA[toUser]]></ToUserName><FromUserName><![CDATA[fromUser]]></FromUserName><CreateTime>1348831860</CreateTime><MsgType><![CDATA[text]]></MsgType><Content><![CDATA[this is a test]]></Content><MsgId>1234567890123456</MsgId></xml>";
var xDoc = XDocument.Parse(xml);
string @event = xDoc.Root!.Element("MsgType")!.Value.ToUpper();
Assert.Equal("TEXT", @event);
}
[Fact(DisplayName = "反序列化 TEXT 事件")]
public void DeserializeTextMessageEventTest()
{