Exemplo n.º 1
0
        public void GetUri_Success()
        {
            var result = new object[3]
            {
                1,
                "",
                "http://192.168.11.4:11311/"
            };

            MXmlRpcClientProtocol.AllInstances.UrlSetString = (t1, t2) => { };
            MMasterProxy.AllInstances.BeginGetUriStringAsyncCallbackObject = (t1, t2, t3, t4) => { t3(null); return null; };
            MMasterProxy.AllInstances.EndGetUriIAsyncResult= (t1, t2) => result;

            var client = new MasterClient(new Uri("http://localhost"));

            client.GetUriAsync("/test").Result.Is(new Uri("http://192.168.11.4:11311/"));
        }
Exemplo n.º 2
0
        public void GetUri_ParameterError()
        {
            var result = new object[3]
            {
                -1,
                "caller_id must be a string",
                ""
            };

            MXmlRpcClientProtocol.AllInstances.UrlSetString = (t1, t2) => { };
            MMasterProxy.AllInstances.BeginGetUriStringAsyncCallbackObject = (t1, t2, t3, t4) => { t3(null); return null; };
            MMasterProxy.AllInstances.EndGetUriIAsyncResult = (t1, t2) => result;

            var client = new MasterClient(new Uri("http://localhost"));

            var ex = AssertEx.Throws<AggregateException>(() => client.GetUriAsync(null).Wait());
            ex.InnerException.Message.Is("caller_id must be a string");
        }