#region Apache License Version 2.0 /*---------------------------------------------------------------- Copyright 2022 Jeffrey Su & Suzhou Senparc Network Technology Co.,Ltd. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. Detail: https://github.com/JeffreySu/WeiXinMPSDK/blob/master/license.md ----------------------------------------------------------------*/ #endregion Apache License Version 2.0 using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading; using System.Threading.Tasks; using System.Xml; using System.Xml.Linq; using Microsoft.VisualStudio.TestTools.UnitTesting; using Senparc.NeuChar; using Senparc.NeuChar.Context; using Senparc.Weixin.Work.Entities; using Senparc.Weixin.Work.Helpers; using Senparc.Weixin.Work.MessageHandlers; using Senparc.Weixin.Work.Test.net6.MessageHandlers; using Senparc.WeixinTests; namespace Senparc.Weixin.Work.Test.MessageHandlers { [TestClass] public partial class WorkMessageHandlersTest:BaseTest { private string testXml = @" "; private string testXml2 = @""; [TestMethod] public void TextTest() { var postModel = new PostModel() { Msg_Signature = "Fill Your Setting", Timestamp = "Fill Your Setting", Nonce = "Fill Your Setting", Token = "Fill Your Setting", EncodingAESKey = "Fill Your Setting", CorpId = "Fill Your Setting" }; var messageHandler = new CustomMessageHandlers(XDocument.Parse(testXml), postModel, 10); Assert.IsNotNull(messageHandler.RequestDocument); Assert.IsNotNull(messageHandler.RequestMessage); Assert.IsNotNull(messageHandler.EncryptPostData); Assert.IsTrue(messageHandler.AgentId == 2); messageHandler.Execute(); Assert.IsNotNull(messageHandler.ResponseDocument); Assert.IsNotNull(messageHandler.ResponseMessage); Console.WriteLine(messageHandler.RequestDocument); } [TestMethod] public void TextTest2() { var postModel = new PostModel() { Msg_Signature = "118b034be74c917464f833cd32fc3f74958b2c93", Timestamp = "1505643268", Nonce = "1504921331", Token = "3J5JTpb4j8Yfk", EncodingAESKey = "XtJUgDlFYncPP3z4V7W6Jv4ietcIFveUn6LP1KzOBNf", CorpId = "" }; var messageHandler = new CustomMessageHandlers(XDocument.Parse(testFileXml), postModel, 10); Assert.IsNotNull(messageHandler.RequestDocument); Assert.IsNotNull(messageHandler.RequestMessage); Assert.IsNotNull(messageHandler.EncryptPostData); Assert.IsTrue(messageHandler.AgentId == 2); messageHandler.Execute(); Assert.IsNotNull(messageHandler.ResponseDocument); Assert.IsNotNull(messageHandler.ResponseMessage); Console.WriteLine(messageHandler.RequestDocument); } private string testFileXml = @" 1518080539 <![CDATA[小冰 piano.wav]]> 10203788 6520106268131360945 "; // // // [TestMethod] public void FileTest() { //数据不全,未开始正式测试 var postModel = new PostModel() { Msg_Signature = "118b034be74c917464f833cd32fc3f74958b2c93", Timestamp = "1505643268", Nonce = "1504921331", Token = "3J5JTpb4j8Yfk", EncodingAESKey = "XtJUgDlFYncPP3z4V7W6Jv4ietcIFveUn6LP1KzOBNf", CorpId = "" }; var messageHandler = new CustomMessageHandlers(XDocument.Parse(testFileXml), postModel, 10); } } }