Ejemplo n.º 1
0
        public void MakeSystemListMethodsCall()
        {
            var proxy = XmlRpcProxyGen.Create <IStateName>();

            proxy.Url = "http://127.0.0.1:11000/";
            proxy
            .SystemListMethods()
            .ShouldBe(new [] { "examples.getStateName" });
        }
Ejemplo n.º 2
0
        public void DeflateCall()
        {
            _encoding = "deflate";
            var proxy = XmlRpcProxyGen.Create <IStateName>();

            proxy.Url = "http://127.0.0.1:11002/";
            proxy.EnableCompression = true;
            proxy.GetStateName(1).ShouldBe("Alabama");
        }
Ejemplo n.º 3
0
        public void Method1Generic()
        {
            ITest2 proxy            = XmlRpcProxyGen.Create <ITest2>();
            XmlRpcClientProtocol cp = (XmlRpcClientProtocol)proxy;

            Assert.IsTrue(cp is ITest2);
            Assert.IsTrue(cp is IXmlRpcProxy);
            Assert.IsTrue(cp is XmlRpcClientProtocol);
        }
Ejemplo n.º 4
0
        public void MakeAsynchronousCallWait()
        {
            IStateName   proxy = (IStateName)XmlRpcProxyGen.Create(typeof(IStateName));
            IAsyncResult asr2  = proxy.BeginGetStateName(1);

            asr2.AsyncWaitHandle.WaitOne();
            string ret2 = proxy.EndGetStateName(asr2);

            Assert.AreEqual("Alabama", ret2);
        }
Ejemplo n.º 5
0
        public void MakeSynchronousCalls()
        {
            IStateName proxy = (IStateName)XmlRpcProxyGen.Create(typeof(IStateName));
            string     ret1  = proxy.GetStateName(1);

            Assert.AreEqual("Alabama", ret1);
            string ret2 = proxy.GetStateName("1");

            Assert.AreEqual("Alabama", ret2);
        }
Ejemplo n.º 6
0
        public void GetCookie()
        {
            var proxy = XmlRpcProxyGen.Create <IStateName>();

            proxy.Url = "http://127.0.0.1:11000/";
            proxy.GetStateName(1);
            var cookies = proxy.ResponseCookies;

            cookies["FooCookie"].Value.ShouldBe("FooValue");
        }
Ejemplo n.º 7
0
        public void GetHeader()
        {
            var proxy = XmlRpcProxyGen.Create <IStateName>();

            proxy.Url = "http://127.0.0.1:11000/";
            proxy.GetStateName(1);
            var headers = proxy.ResponseHeaders;

            headers["BarHeader"].ShouldBe("BarValue");
        }
Ejemplo n.º 8
0
        public void BuildProxy()
        {
            Type       newType = XmlRpcProxyGen.Create(typeof(IFoo)).GetType();
            MethodInfo mi      = newType.GetMethod("Foo");

            ParameterInfo[] pis = mi.GetParameters();
            Assert.IsTrue(
                Attribute.IsDefined(pis[pis.Length - 1], typeof(ParamArrayAttribute)),
                "method has params argument");
        }
Ejemplo n.º 9
0
        public void MakeAsynchronousCallCallbackNoState()
        {
            IStateName proxy = (IStateName)XmlRpcProxyGen.Create(typeof(IStateName));

            _evt = new ManualResetEvent(false);
            IAsyncResult asr3 = proxy.BeginGetStateName(1, StateNameCallbackNoState);

            _evt.WaitOne();
            Assert.AreEqual(null, _excep, "Async call threw exception");
            Assert.AreEqual("Alabama", _ret);
        }
Ejemplo n.º 10
0
        public void MakeAsynchronousCallIsCompleted()
        {
            IStateName   proxy = (IStateName)XmlRpcProxyGen.Create(typeof(IStateName));
            IAsyncResult asr1  = proxy.BeginGetStateName(1);

            while (asr1.IsCompleted == false)
            {
                System.Threading.Thread.Sleep(10);
            }
            string ret1 = proxy.EndGetStateName(asr1);

            Assert.AreEqual("Alabama", ret1);
        }
Ejemplo n.º 11
0
        public void RequestEvent()
        {
            string response = null;
            var    proxy    = XmlRpcProxyGen.Create <IStateName>();

            proxy.Url = "http://127.0.0.1:11000/";
            proxy.AllowAutoRedirect = false;
            proxy.RequestEvent     += (sender, args) =>
            {
                response = args.ProxyID.ToString();
            };
            proxy.GetStateName(1);
            response.ShouldNotBeNull();
        }
Ejemplo n.º 12
0
        public void FileIOPermission()
        {
            var f = new FileIOPermission(PermissionState.Unrestricted);

            f.Deny();
            try
            {
                IStateName2 proxy = (IStateName2)XmlRpcProxyGen.Create(typeof(IStateName2));
            }
            finally
            {
                CodeAccessPermission.RevertDeny();
            }
        }
Ejemplo n.º 13
0
        public void SynchronousFaultException()
        {
            IStateName proxy = (IStateName)XmlRpcProxyGen.Create(typeof(IStateName));

            try
            {
                string ret1 = proxy.GetStateName(100);
                Assert.Fail("exception not thrown on sync call");
            }
            catch (XmlRpcFaultException fex)
            {
                Assert.AreEqual(1, fex.FaultCode);
                Assert.AreEqual("Invalid state number", fex.FaultString);
            }
        }
Ejemplo n.º 14
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);
            }
        }
Ejemplo n.º 15
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);
        }
Ejemplo n.º 16
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);
        }
Ejemplo n.º 17
0
 public void Method1()
 {
     var proxy = (ITest)XmlRpcProxyGen.Create(typeof(ITest));
     XmlRpcClientProtocol cp = (XmlRpcClientProtocol)proxy;
 }
Ejemplo n.º 18
0
 public void Overrides()
 {
     IOverrides proxy = (IOverrides)XmlRpcProxyGen.Create(typeof(IOverrides));
 }
Ejemplo n.º 19
0
 public void OverridesChild()
 {
     IOverridesChild proxy = (IOverridesChild)XmlRpcProxyGen.Create(typeof(IOverridesChild));
 }
Ejemplo n.º 20
0
 public void ListMethods()
 {
     IChild proxy = (IChild)XmlRpcProxyGen.Create(typeof(IChild));
 }
Ejemplo n.º 21
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));
 }