Beispiel #1
0
        public void LocationMessageReceivedEventArgs()
        {
            string s = @"<xml>
  <ToUserName><![CDATA[gh_712b448adf85]]></ToUserName>
<FromUserName><![CDATA[oI3UkuL9uZxTOuj--HHMSMTlO3ks]]></FromUserName>
<CreateTime>1490872329</CreateTime>
<MsgType><![CDATA[text]]></MsgType>
<Location_X>23.134521</Location_X>
<Location_Y>113.358803</Location_Y>
<Scale>20</Scale>
<Label><![CDATA[位置信息]]></Label>
<MsgId>6403247895999455936</MsgId>
</xml>";

            var result = XmlConvert.DeserializeObject <LocationMessageReceivedEventArgs>(s);

            Assert.Equal("gh_712b448adf85", result.ToUserName);
            Assert.Equal("oI3UkuL9uZxTOuj--HHMSMTlO3ks", result.FromUserName);
            Assert.Equal(1490872329, WeixinTimestampHelper.FromLocalTime(result.CreateTime));
            Assert.Equal(ReceivedMsgType.text, result.MsgType);
            Assert.Equal((decimal)23.134521, result.Latitude);
            Assert.Equal((decimal)113.358803, result.Longitude);
            Assert.Equal(20, result.Scale);
            Assert.Equal("位置信息", result.Label);
            Assert.Equal(6403247895999455936, result.MsgId);
        }
Beispiel #2
0
        public void SubscribeEventReceivedEventArgs()
        {
            string s = @"<xml><ToUserName><![CDATA[gh_712b448adf85]]></ToUserName>
<FromUserName><![CDATA[oI3UkuL9uZxTOuj--HHMSMTlO3ks]]></FromUserName>
<CreateTime>1490872329</CreateTime>
<MsgType><![CDATA[event]]></MsgType>
<Event><![CDATA[subscribe]]></Event>
</xml>";

            var result = XmlConvert.DeserializeObject <SubscribeEventReceivedEventArgs>(s);

            Assert.Equal("gh_712b448adf85", result.ToUserName);
            Assert.Equal("oI3UkuL9uZxTOuj--HHMSMTlO3ks", result.FromUserName);
            Assert.Equal(1490872329, WeixinTimestampHelper.FromLocalTime(result.CreateTime));
            Assert.Equal(ReceivedMsgType.@event, result.MsgType);
            Assert.Equal(ReceivedEventType.subscribe, result.Event);
        }
Beispiel #3
0
        public void ReceivedEventArgs()
        {
            string s = @"<xml>
  <ToUserName><![CDATA[gh_712b448adf85]]></ToUserName>
<FromUserName><![CDATA[oI3UkuL9uZxTOuj--HHMSMTlO3ks]]></FromUserName>
<CreateTime>1490872329</CreateTime>
<MsgType><![CDATA[text]]></MsgType>
<Content><![CDATA[中文字符]]></Content>
<MsgId>6403247895999455936</MsgId>
</xml>";

            var result = XmlConvert.DeserializeObject <ReceivedEventArgs>(s);

            Assert.Equal("gh_712b448adf85", result.ToUserName);
            Assert.Equal("oI3UkuL9uZxTOuj--HHMSMTlO3ks", result.FromUserName);
            Assert.Equal(1490872329, WeixinTimestampHelper.FromLocalTime(result.CreateTime));
            Assert.Equal(ReceivedMsgType.text, result.MsgType);
        }
Beispiel #4
0
        public void ImageMessageReceivedEventArgs()
        {
            string s = @"<xml>
  <ToUserName><![CDATA[gh_712b448adf85]]></ToUserName>
<FromUserName><![CDATA[oI3UkuL9uZxTOuj--HHMSMTlO3ks]]></FromUserName>
<CreateTime>1490872329</CreateTime>
<MsgType><![CDATA[text]]></MsgType>
<PicUrl><![CDATA[this is a url]]></PicUrl>
<MediaId><![CDATA[media_id]]></MediaId>
<MsgId>6403247895999455936</MsgId>
</xml>";

            var result = XmlConvert.DeserializeObject <ImageMessageReceivedEventArgs>(s);

            Assert.Equal("gh_712b448adf85", result.ToUserName);
            Assert.Equal("oI3UkuL9uZxTOuj--HHMSMTlO3ks", result.FromUserName);
            Assert.Equal(1490872329, WeixinTimestampHelper.FromLocalTime(result.CreateTime));
            Assert.Equal(ReceivedMsgType.text, result.MsgType);
            Assert.Equal("this is a url", result.PicUrl);
            Assert.Equal("media_id", result.MediaId);
            Assert.Equal(6403247895999455936, result.MsgId);
        }
Beispiel #5
0
        public void QrscanEventReceivedEventArgs()
        {
            string s = @"<xml><ToUserName><![CDATA[gh_712b448adf85]]></ToUserName>
<FromUserName><![CDATA[oI3UkuL9uZxTOuj--HHMSMTlO3ks]]></FromUserName>
<CreateTime>1490872329</CreateTime>
<MsgType><![CDATA[event]]></MsgType>
<Event><![CDATA[SCAN]]></Event>
<EventKey><![CDATA[123123]]></EventKey>
<Ticket><![CDATA[gQE28TwAAAAAAAAAAS5odHRwOi8vd2VpeGluLnFxLmNvbS9xLzAyUkhQZWgzelI4QVUxMDAwMGcwN3kAAgR6ittYAwQAAAAA]]></Ticket>
</xml>";

            var result = XmlConvert.DeserializeObject <QrscanEventReceivedEventArgs>(s);

            Assert.Equal("gh_712b448adf85", result.ToUserName);
            Assert.Equal("oI3UkuL9uZxTOuj--HHMSMTlO3ks", result.FromUserName);
            Assert.Equal(1490872329, WeixinTimestampHelper.FromLocalTime(result.CreateTime));
            Assert.Equal(ReceivedMsgType.@event, result.MsgType);
            Assert.Equal(ReceivedEventType.SCAN, result.Event);
            Assert.Equal("123123", result.EventKey);
            Assert.Equal("123123", result.Scene);
            Assert.Equal("gQE28TwAAAAAAAAAAS5odHRwOi8vd2VpeGluLnFxLmNvbS9xLzAyUkhQZWgzelI4QVUxMDAwMGcwN3kAAgR6ittYAwQAAAAA", result.Ticket);
        }
Beispiel #6
0
        public void LocationEventReceivedEventArgs()
        {
            string s = @"<xml><ToUserName><![CDATA[gh_712b448adf85]]></ToUserName>
<FromUserName><![CDATA[oI3UkuL9uZxTOuj--HHMSMTlO3ks]]></FromUserName>
<CreateTime>1490872329</CreateTime>
<MsgType><![CDATA[event]]></MsgType>
<Event><![CDATA[LOCATION]]></Event>
<Latitude>23.137466</Latitude>
<Longitude>113.352425</Longitude>
<Precision>119.385040</Precision>
</xml>";

            var result = XmlConvert.DeserializeObject <LocationEventReceivedEventArgs>(s);

            Assert.Equal("gh_712b448adf85", result.ToUserName);
            Assert.Equal("oI3UkuL9uZxTOuj--HHMSMTlO3ks", result.FromUserName);
            Assert.Equal(1490872329, WeixinTimestampHelper.FromLocalTime(result.CreateTime));
            Assert.Equal(ReceivedMsgType.@event, result.MsgType);
            Assert.Equal(ReceivedEventType.LOCATION, result.Event);
            Assert.Equal((decimal)23.137466, result.Latitude);
            Assert.Equal((decimal)113.352425, result.Longitude);
            Assert.Equal((decimal)119.385040, result.Precision);
        }
Beispiel #7
0
        public void LinkMessageReceivedEventArgs()
        {
            string s = @"<xml>
  <ToUserName><![CDATA[gh_712b448adf85]]></ToUserName>
<FromUserName><![CDATA[oI3UkuL9uZxTOuj--HHMSMTlO3ks]]></FromUserName>
<CreateTime>1490872329</CreateTime>
<MsgType><![CDATA[text]]></MsgType>
<Title><![CDATA[我的官网]]></Title>
<Description><![CDATA[公众平台官网链接]]></Description>
<Url><![CDATA[http://url.com/q?something]]></Url>
<MsgId>6403247895999455936</MsgId>
</xml>";

            var result = XmlConvert.DeserializeObject <LinkMessageReceivedEventArgs>(s);

            Assert.Equal("gh_712b448adf85", result.ToUserName);
            Assert.Equal("oI3UkuL9uZxTOuj--HHMSMTlO3ks", result.FromUserName);
            Assert.Equal(1490872329, WeixinTimestampHelper.FromLocalTime(result.CreateTime));
            Assert.Equal(ReceivedMsgType.text, result.MsgType);
            Assert.Equal("我的官网", result.Title);
            Assert.Equal("公众平台官网链接", result.Description);
            Assert.Equal("http://url.com/q?something", result.Url);
            Assert.Equal(6403247895999455936, result.MsgId);
        }
Beispiel #8
0
        public void VoiceMessageReceivedEventArgs_WithRecognition()
        {
            string s = @"<xml>
  <ToUserName><![CDATA[gh_712b448adf85]]></ToUserName>
<FromUserName><![CDATA[oI3UkuL9uZxTOuj--HHMSMTlO3ks]]></FromUserName>
<CreateTime>1490872329</CreateTime>
<MsgType><![CDATA[text]]></MsgType>
<MediaId><![CDATA[media_id]]></MediaId>
<Format><![CDATA[Format]]></Format>
<Recognition><![CDATA[腾讯微信团队]]></Recognition>
<MsgId>6403247895999455936</MsgId>
</xml>";

            var result = XmlConvert.DeserializeObject <VoiceMessageReceivedEventArgs>(s);

            Assert.Equal("gh_712b448adf85", result.ToUserName);
            Assert.Equal("oI3UkuL9uZxTOuj--HHMSMTlO3ks", result.FromUserName);
            Assert.Equal(1490872329, WeixinTimestampHelper.FromLocalTime(result.CreateTime));
            Assert.Equal(ReceivedMsgType.text, result.MsgType);
            Assert.Equal("media_id", result.MediaId);
            Assert.Equal("Format", result.Format);
            Assert.Equal("腾讯微信团队", result.Recognition);
            Assert.Equal(6403247895999455936, result.MsgId);
        }