Пример #1
0
        public void RequestMessageStreamSerialize()
        {
            MessageStream  requestStream = MessageStream.NewRequest();
            RequestMessage request       = new RequestMessage("testMethod1");

            request.Arguments.Add(true);
            requestStream.AddMessage(request);
            request = new RequestMessage("testMethod2");
            request.Arguments.Add("test");
            request.Arguments.Add(false);
            requestStream.AddMessage(request);

            string s = Serialize(requestStream);

            StringBuilder sb = new StringBuilder();

            sb.Append("<?xml version=\"1.0\" encoding=\"utf-8\" standalone=\"yes\"?>");
            sb.Append("<messageStream>");
            sb.Append("<message>");
            sb.Append("<methodCall>");
            sb.Append("<methodName>testMethod1</methodName>");
            sb.Append("<params><param><value><boolean>1</boolean></value></param></params>");
            sb.Append("</methodCall>");
            sb.Append("</message>");
            sb.Append("<message>");
            sb.Append("<methodCall>");
            sb.Append("<methodName>testMethod2</methodName>");
            sb.Append("<params><param><value><string>test</string></value></param><param><value><boolean>0</boolean></value></param></params>");
            sb.Append("</methodCall>");
            sb.Append("</message>");
            sb.Append("</messageStream>");

            Console.Out.WriteLine("Generated:");
            Console.Out.WriteLine(s);

            Assert.AreEqual(sb.ToString(), s);
        }