public void GetResponseEntityTest() { { //Text ResponseMessageText exceptResult = new ResponseMessageText() { ToUserName = "******", FromUserName = "******", CreateTime = DateTimeHelper.GetDateTimeFromXml(63497820384), //MsgType = ResponseMsgType.Text, Content = "文字信息", FuncFlag = false }; var result = ResponseMessageFactory.GetResponseEntity(xmlText) as ResponseMessageText; Assert.AreEqual(exceptResult.ToUserName, result.ToUserName); Assert.AreEqual(exceptResult.CreateTime, result.CreateTime); Assert.AreEqual(exceptResult.Content, result.Content); } { //Image ResponseMessageNews exceptResult = new ResponseMessageNews() { //Articles = new List<Article>(), CreateTime = DateTimeHelper.GetDateTimeFromXml(63497821905), FromUserName = "******", ToUserName = "******", FuncFlag = false, //MsgType = ResponseMsgType.News }; var result = ResponseMessageFactory.GetResponseEntity(xmlNews) as ResponseMessageNews; Assert.AreEqual(exceptResult.ToUserName, result.ToUserName); Assert.AreEqual(exceptResult.CreateTime, result.CreateTime); Assert.AreEqual(2, result.ArticleCount); Assert.AreEqual(result.Articles.Count, result.ArticleCount); } { //Music ResponseMessageMusic exceptResult = new ResponseMessageMusic() { Music = new Music() { Title = "标题", Description = "说明", MusicUrl = "http://weixin.senparc.com/Content/music1.mp3", HQMusicUrl = "" }, CreateTime = DateTimeHelper.GetDateTimeFromXml(63497823450), FromUserName = "******", ToUserName = "******", FuncFlag = false, //MsgType = ResponseMsgType.Music }; var result = ResponseMessageFactory.GetResponseEntity(xmlMusic) as ResponseMessageMusic; Assert.AreEqual(exceptResult.ToUserName, result.ToUserName); Assert.AreEqual(exceptResult.CreateTime, result.CreateTime); //Assert.AreEqual(exceptResult.Music, result.Music); } }