예제 #1
0
파일: Program.cs 프로젝트: stzva/json-ws
        private static void TestMethods()
        {
            using (var proxy = new GeneratedTest("http://localhost:3000/endpoint/1.0"))
            {
                try
                {
                    Console.WriteLine(proxy/*.UseWS()*/.ThrowError().Result);
                }
                catch (Exception e)
                {
                    Console.WriteLine(e.ToString());
                }

                var task = proxy.Sum(1, 2);
                Console.WriteLine(task.Result);

                var r = new GeneratedTest.RenderOptions {width = 1, height = 2, renderMode = GeneratedTest.RenderMode.Production};
                var taskEcho = proxy.Echo(r);
                Console.WriteLine(taskEcho.Result.ToString());

                var o = new JObject();
                o["a"] = JToken.FromObject(new[] { 1, 2 });
                var taskEcho2 = proxy.EchoObject(o);
                Console.WriteLine(taskEcho2.Result.ToString());

                // binary message
                var bytes = proxy.EchoStringAsBuffer("binary").Result;
                Console.WriteLine("bytes: {0}, message: {1}", bytes.Length,
                    System.Text.Encoding.Default.GetString(bytes));

                var bytesLength = proxy.GetBufferSize(bytes).Result;
                Console.WriteLine("bytes buffer size: {0}", bytesLength);
            }
        }
예제 #2
0
        private void TestMethods(GeneratedTest proxy)
        {
            try
            {
                Console.WriteLine(proxy.ThrowError().Result);
                Assert.Fail("Server-side exception was not rethrown on the client");
            }
            catch (Exception)
            {
            }

            var task = proxy.Sum(1, 2);

            Assert.AreEqual(task.Result, 3);

            var r = new GeneratedTest.RenderOptions {
                width = 1, height = 2, renderMode = GeneratedTest.RenderMode.Production
            };
            var taskEcho = proxy.Echo(r);

            Assert.AreEqual(r.width, taskEcho.Result.width);
            Assert.AreEqual(r.height, taskEcho.Result.height);
            Assert.AreEqual(r.renderMode, taskEcho.Result.renderMode);

            var o = new JObject();

            o["a"] = JToken.FromObject(new[] { 1, 2 });
            var taskEcho2 = proxy.EchoObject(o);

            Assert.AreEqual(o["a"].ToString(), taskEcho2.Result["a"].ToString());

            var bytes = proxy.EchoStringAsBuffer("binary").Result;

            Assert.AreEqual("binary", Encoding.UTF8.GetString(bytes));

            var bytesLength = proxy.GetBufferSize(bytes).Result;

            Assert.AreEqual(bytes.LongLength, bytesLength);
        }
예제 #3
0
        private static void TestMethods()
        {
            using (var proxy = new GeneratedTest("http://localhost:3000/endpoint/1.0"))
            {
                try
                {
                    Console.WriteLine(proxy /*.UseWS()*/.ThrowError().Result);
                }
                catch (Exception e)
                {
                    Console.WriteLine(e.ToString());
                }

                var task = proxy.Sum(1, 2);
                Console.WriteLine(task.Result);

                var r = new GeneratedTest.RenderOptions {
                    width = 1, height = 2, renderMode = GeneratedTest.RenderMode.Production
                };
                var taskEcho = proxy.Echo(r);
                Console.WriteLine(taskEcho.Result.ToString());

                var o = new JObject();
                o["a"] = JToken.FromObject(new[] { 1, 2 });
                var taskEcho2 = proxy.EchoObject(o);
                Console.WriteLine(taskEcho2.Result.ToString());

                // binary message
                var bytes = proxy.EchoStringAsBuffer("binary").Result;
                Console.WriteLine("bytes: {0}, message: {1}", bytes.Length,
                                  System.Text.Encoding.Default.GetString(bytes));

                var bytesLength = proxy.GetBufferSize(bytes).Result;
                Console.WriteLine("bytes buffer size: {0}", bytesLength);
            }
        }
예제 #4
0
파일: tests.cs 프로젝트: stzva/json-ws
        private void TestMethods(GeneratedTest proxy)
        {
            try
            {
                Console.WriteLine(proxy.ThrowError().Result);
                Assert.Fail("Server-side exception was not rethrown on the client");
            }
            catch (Exception)
            {
            }

            var task = proxy.Sum(1, 2);
            Assert.AreEqual(task.Result, 3);

            var r = new GeneratedTest.RenderOptions { width = 1, height = 2, renderMode = GeneratedTest.RenderMode.Production };
            var taskEcho = proxy.Echo(r);
            Assert.AreEqual(r.width, taskEcho.Result.width);
            Assert.AreEqual(r.height, taskEcho.Result.height);
            Assert.AreEqual(r.renderMode, taskEcho.Result.renderMode);

            var o = new JObject();
            o["a"] = JToken.FromObject(new[] { 1, 2 });
            var taskEcho2 = proxy.EchoObject(o);
            Assert.AreEqual(o["a"].ToString(), taskEcho2.Result["a"].ToString());

            var bytes = proxy.EchoStringAsBuffer("binary").Result;
            Assert.AreEqual("binary", Encoding.UTF8.GetString(bytes));

            var bytesLength = proxy.GetBufferSize(bytes).Result;
            Assert.AreEqual(bytes.LongLength, bytesLength);
        }