Example #1
0
        public void TestArbitrary()
        {
            AutoResetEvent are = new AutoResetEvent(false);
            var client = new AustinHarris.JsonRpc.JsonRpcClient(remoteUri);
            var arbitrary = new Newtonsoft.Json.Linq.JObject();
            JObject r = null;
            Exception e = null;
            for (int i = 0; i < 10; i++)
            {
                arbitrary[getPrintableString(10)] = getPrintableString(20);
                arbitrary[getNonPrintableString(10)] = getNonPrintableString(20);
                arbitrary[getExtendedAsciiString(10)] = getExtendedAsciiString(20);
            }

            var myObs = client.Invoke<Newtonsoft.Json.Linq.JObject>("testArbitraryJObject", arbitrary, Scheduler.TaskPool);

            using(myObs.Subscribe(
                onNext: (jo) =>
                {
                   r = jo.Result;
                },
                onError:   _ =>
                {
                    e = _;
                },
                onCompleted: () => are.Set()
                ))
            {
                are.WaitOne();
            };

            
            Assert.IsTrue(r.ToString() == arbitrary.ToString());
            Assert.IsTrue(e == null);
        }
Example #2
0
        public void TestRpcPerSecond()
        {
            // This test sometimes fails due to overloading
            // the network buffer
            var client        = new AustinHarris.JsonRpc.JsonRpcClient(remoteUri);
            var abjo          = CreateArbitraryJObject();
            var limit         = 50;
            var passes        = 5;
            var requestStream = Observable.Generate <int, JObject>(0,
                                                                   i => i < limit,
                                                                   i => i + 1,
                                                                   i => abjo
                                                                   );

            for (int i = 0; i < passes; i++)
            {
                var tmr = Stopwatch.StartNew();
                SendRequestsAndWait(client, requestStream);
                tmr.Stop();
                var perSecond = (decimal)limit * (1000 / (decimal)tmr.ElapsedMilliseconds);
                Console.WriteLine("Pass{0} - {1} requests in : {2}ms for {3} requests per second", i, limit, tmr.ElapsedMilliseconds, (int)perSecond);
                limit = limit * 2;
                Thread.Sleep(200);
            }
        }
Example #3
0
        public void TestHelloWorld()
        {
            AutoResetEvent are = new AutoResetEvent(false);
            var client = new AustinHarris.JsonRpc.JsonRpcClient(remoteUri);
            var myObs = client.Invoke<string>("helloWorld", "My Message", Scheduler.TaskPool);

            using (myObs.Subscribe(
                onNext: _ =>
                {
                    Console.WriteLine(_.Result);
                    Assert.IsTrue(_.Result == "Hello World My Message");
                },
                onError: _ =>
                {
                    Assert.Fail();
                    are.Set();
                },
                onCompleted: () => are.Set()
                ))
            {
                are.WaitOne();
            }
        }
Example #4
0
        public void TestHelloWorld()
        {
            AutoResetEvent are    = new AutoResetEvent(false);
            var            client = new AustinHarris.JsonRpc.JsonRpcClient(remoteUri);
            var            myObs  = client.Invoke <string>("helloWorld", "My Message", Scheduler.TaskPool);

            using (myObs.Subscribe(
                       onNext: _ =>
            {
                Console.WriteLine(_.Result);
                Assert.IsTrue(_.Result == "Hello World My Message");
            },
                       onError: _ =>
            {
                Assert.Fail();
                are.Set();
            },
                       onCompleted: () => are.Set()
                       ))
            {
                are.WaitOne();
            }
        }
Example #5
0
        public void TestArbitrary()
        {
            AutoResetEvent are       = new AutoResetEvent(false);
            var            client    = new AustinHarris.JsonRpc.JsonRpcClient(remoteUri);
            var            arbitrary = new Newtonsoft.Json.Linq.JObject();
            JObject        r         = null;
            Exception      e         = null;

            for (int i = 0; i < 10; i++)
            {
                arbitrary[getPrintableString(10)]     = getPrintableString(20);
                arbitrary[getNonPrintableString(10)]  = getNonPrintableString(20);
                arbitrary[getExtendedAsciiString(10)] = getExtendedAsciiString(20);
            }

            var myObs = client.Invoke <Newtonsoft.Json.Linq.JObject>("testArbitraryJObject", arbitrary, Scheduler.TaskPool);

            using (myObs.Subscribe(
                       onNext: (jo) =>
            {
                r = jo.Result;
            },
                       onError:   _ =>
            {
                e = _;
            },
                       onCompleted: () => are.Set()
                       ))
            {
                are.WaitOne();
            };


            Assert.IsTrue(r.ToString() == arbitrary.ToString());
            Assert.IsTrue(e == null);
        }
Example #6
0
 public void TestRpcPerSecond()
 {
     // This test sometimes fails due to overloading
     // the network buffer
     var client = new AustinHarris.JsonRpc.JsonRpcClient(remoteUri);
     var abjo = CreateArbitraryJObject();
     var limit = 50;
     var passes = 5;
     var requestStream = Observable.Generate<int, JObject>(0,
                                     i => i < limit,
                                     i => i+1,
                                     i => abjo
                                     );
     for (int i = 0; i < passes; i++)
     {
         var tmr = Stopwatch.StartNew();
         SendRequestsAndWait(client, requestStream);
         tmr.Stop();
         var perSecond = (decimal)limit  * (1000 / (decimal)tmr.ElapsedMilliseconds);
         Console.WriteLine("Pass{0} - {1} requests in : {2}ms for {3} requests per second", i, limit, tmr.ElapsedMilliseconds, (int)perSecond);
         limit = limit * 2;
         Thread.Sleep(200);
     }            
 }