public void CallMessageFromCallBuilder()
        {
            var p = new ProtocolObjectFactory();

            byte[] buffer;
            using (var s = new MemoryStream())
            {
                var call = new RpcCallParameters();
                call.ServiceName = this.serviceName;
                call.MethodName  = this.methodName;
                call.IsAsync     = this.isAsync;
                call.ObjectId    = this.objectId;
                call.CallData    = this.callData;
                var c = p.BuildCall(call);
                p.WriteMessage(s, this.requestId, c, null);
                buffer = s.ToArray();
            }

            using (var s = new MemoryStream(buffer))
            {
                var message = p.RpcMessageFromStream(s);
                Assert.That(s.Position, Is.EqualTo(s.Length));

                Assert.That(message.RequestId, Is.EqualTo(this.requestId));
                Assert.That(message.Call, Is.Not.Null);
                Assert.That(message.Result, Is.Null);

                Assert.That(message.Call.ObjectId, Is.EqualTo(this.objectId));
                Assert.That(message.Call.ServiceName, Is.EqualTo(this.serviceName));
                Assert.That(message.Call.MethodName, Is.EqualTo(this.methodName));
                Assert.That(message.Call.IsAsync, Is.EqualTo(this.isAsync));
                Assert.That(message.Call.CallData, Is.EquivalentTo(this.callData));
            }
        }
Exemple #2
0
 public RpcCall(RpcCallParameters callParameters)
 {
     this.IsAsync     = callParameters.IsAsync;
     this.ServiceName = callParameters.ServiceName;
     this.MethodName  = callParameters.MethodName;
     this.ObjectId    = callParameters.ObjectId;
     this.CallData    = callParameters.CallData;
 }
        public void CallBuilderDefaults()
        {
            var p = new ProtocolObjectFactory();
            var c = new RpcCallParameters();

            Assert.That(c, Is.Not.Null);
            Assert.That(c.ServiceName, Is.Null);
            Assert.That(c.MethodName, Is.Null);
            Assert.That(c.IsAsync, Is.False);
            Assert.That(c.ObjectId, Is.EqualTo(0));
            Assert.That(c.CallData, Is.Null);
        }
Exemple #4
0
        public void Method_V_V()
        {
            var call = new RpcCallParameters();

            call.ServiceName = TestServiceInterface_Proxy.ServiceName;
            call.MethodName  = "Method_V_V";
            var result = this.client.CallService(call);

            if (result.Status != RpcStatus.Succeeded)
            {
                throw new Exception(); // TODO: Be more specific
            }
        }
Exemple #5
0
        public void Method_V_M(StructType value)
        {
            var call = new RpcCallParameters();

            call.ServiceName = TestServiceInterface_Proxy.ServiceName;
            call.MethodName  = "Method_V_M";
            call.CallData    = value.ToByteArray();
            var result = this.client.CallService(call);

            if (result.Status != RpcStatus.Succeeded)
            {
                throw new Exception(); // TODO: Be more specific
            }
        }
Exemple #6
0
        public void Test1()
        {
            var client = new RpcClient(new FakeClientTransport());

            client.Connect();
            var callMessage = new RpcCallParameters
            {
                ServiceName = "Service",
                MethodName  = "Test",
                CallData    = new byte[] { 1, 3, 5, 7 }
            };
            var result = client.CallService(callMessage);

            Assert.That(result.Status, Is.EqualTo(RpcStatus.Succeeded));
            Assert.That(result.ResultData, Is.EquivalentTo(new byte[] { 2, 4, 6, 8 }));
            client.Shutdown(false);
        }
Exemple #7
0
        public StructType Method_M_V()
        {
            var call = new RpcCallParameters();

            call.ServiceName = TestServiceInterface_Proxy.ServiceName;
            call.MethodName  = "Method_M_V";
            var result = this.client.CallService(call);

            if (result.Status != RpcStatus.Succeeded)
            {
                throw new Exception(); // TODO: Be more specific
            }

            var returnValue = new StructType();

            returnValue.MergeFrom(result.ResultData);
            return(returnValue);
        }
        public void CallBuilderProperties()
        {
            var p = new ProtocolObjectFactory();
            var c = new RpcCallParameters();

            Assume.That(c, Is.Not.Null);

            c.ServiceName = this.serviceName;
            c.MethodName  = this.methodName;
            c.IsAsync     = this.isAsync;
            c.ObjectId    = this.objectId;
            c.CallData    = this.callData;

            Assert.That(c.ServiceName, Is.EqualTo(this.serviceName));
            Assert.That(c.MethodName, Is.EqualTo(this.methodName));
            Assert.That(c.IsAsync, Is.EqualTo(this.isAsync));
            Assert.That(c.ObjectId, Is.EqualTo(this.objectId));
            Assert.That(c.CallData, Is.EquivalentTo(this.callData));
        }
Exemple #9
0
        public int Ping(int value)
        {
            var call = new RpcCallParameters();

            call.ServiceName = "IPingPong";
            call.MethodName  = "Ping";
            call.CallData    = BitConverter.GetBytes(value);
            var result = this.client.CallService(call);

            if (result.Status == RpcStatus.ChannelFailure)
            {
                throw new RpcException(result.Status);
            }
            else if (result.Status != RpcStatus.Succeeded)
            {
                throw new ApplicationException();
            }

            return(BitConverter.ToInt32(result.ResultData, 0));
        }
Exemple #10
0
 public IRpcCall BuildCall(RpcCallParameters callParameters)
 {
     return(new RpcCall(callParameters));
 }
Exemple #11
0
 public void SendEvent(RpcCallParameters rpcCall)
 {
     this.server.SendEvent(rpcCall, null);
 }