Example #1
0
        public void AsynchronousFaultException()
        {
            IStateName   proxy = (IStateName)XmlRpcProxyGen.Create(typeof(IStateName));
            IAsyncResult asr   = proxy.BeginGetStateName(100);

            asr.AsyncWaitHandle.WaitOne();
            try
            {
                string ret = proxy.EndGetStateName(asr);
                Assert.Fail("exception not thrown on async call");
            }
            catch (XmlRpcFaultException fex)
            {
                Assert.AreEqual(1, fex.FaultCode);
                Assert.AreEqual("Invalid state number", fex.FaultString);
            }
        }
Example #2
0
        public void Logging()
        {
            string     expectedRequest     = @"<?xml version=""1.0""?>
<methodCall>
  <methodName>examples.getStateName</methodName>
  <params>
    <param>
      <value>
        <i4>1</i4>
      </value>
    </param>
  </params>
</methodCall>";
            string     expectedResponseXml = @"<?xml version=""1.0""?>
<methodResponse>
  <params>
    <param>
      <value>
        <string>Alabama</string>
      </value>
    </param>
  </params>
</methodResponse>";
            string     requestXml          = null;
            string     responseXml         = null;
            IStateName proxy = (IStateName)XmlRpcProxyGen.Create(typeof(IStateName));

            proxy.RequestEvent += delegate(object sender, XmlRpcRequestEventArgs args)
            {
                requestXml = GetXml(args.RequestStream);
            };
            proxy.ResponseEvent += delegate(object sender, XmlRpcResponseEventArgs args)
            {
                responseXml = GetXml(args.ResponseStream);
            };
            string ret = proxy.GetStateName(1);

            Assert.AreEqual("Alabama", ret);
            Assert.AreEqual(expectedRequest, requestXml);
            Assert.AreEqual(expectedResponseXml, responseXml);
        }
Example #3
0
 public void ListMethods()
 {
     IChild proxy = (IChild)XmlRpcProxyGen.Create(typeof(IChild));
 }
Example #4
0
 public void InheritedInterface()
 {
     // Test problem reported by Sean Rohead. This will throw an exception
     // if method Foo in the base class Parent is not implemented
     IChild proxy = (IChild)XmlRpcProxyGen.Create(typeof(IChild));
 }
Example #5
0
 public void OverridesChild()
 {
     IOverridesChild proxy = (IOverridesChild)XmlRpcProxyGen.Create(typeof(IOverridesChild));
 }
Example #6
0
 public void Overrides()
 {
     IOverrides proxy = (IOverrides)XmlRpcProxyGen.Create(typeof(IOverrides));
 }
Example #7
0
 public void Method1()
 {
     var proxy = (ITest)XmlRpcProxyGen.Create(typeof(ITest));
     XmlRpcClientProtocol cp = (XmlRpcClientProtocol)proxy;
 }
Example #8
0
        public void SerializeWithMappingOnMethod()
        {
            Stream        stm = new MemoryStream();
            XmlRpcRequest req = new XmlRpcRequest();

            req.Args = new object[] {
                IntEnum.Zero, new[] { IntEnum.One, IntEnum.Two },
                new IntEnumClass {
                    IntEnum  = IntEnum.One,
                    intEnum  = IntEnum.Two,
                    IntEnums = new[] { IntEnum.One, IntEnum.Two },
                    intEnums = new[] { IntEnum.Three, IntEnum.Four },
                }
            };
            req.Method = "MappingOnMethod";
            var proxy = XmlRpcProxyGen.Create <TestMethods1>();

            req.Mi = proxy.GetType().GetMethod("MappingOnMethod");
            var ser = new XmlRpcRequestSerializer();

            ser.SerializeRequest(stm, req);
            stm.Position = 0;
            TextReader tr     = new StreamReader(stm);
            string     reqstr = tr.ReadToEnd();

            Assert.AreEqual(@"<?xml version=""1.0""?>
<methodCall>
  <methodName>MappingOnMethod</methodName>
  <params>
    <param>
      <value>
        <string>Zero</string>
      </value>
    </param>
    <param>
      <value>
        <array>
          <data>
            <value>
              <string>One</string>
            </value>
            <value>
              <string>Two</string>
            </value>
          </data>
        </array>
      </value>
    </param>
    <param>
      <value>
        <struct>
          <member>
            <name>IntEnum</name>
            <value>
              <string>One</string>
            </value>
          </member>
          <member>
            <name>IntEnums</name>
            <value>
              <array>
                <data>
                  <value>
                    <string>One</string>
                  </value>
                  <value>
                    <string>Two</string>
                  </value>
                </data>
              </array>
            </value>
          </member>
          <member>
            <name>intEnum</name>
            <value>
              <string>Two</string>
            </value>
          </member>
          <member>
            <name>intEnums</name>
            <value>
              <array>
                <data>
                  <value>
                    <string>Three</string>
                  </value>
                  <value>
                    <string>Four</string>
                  </value>
                </data>
              </array>
            </value>
          </member>
        </struct>
      </value>
    </param>
  </params>
</methodCall>", reqstr);
        }