public void TestBuiltinException()
        {
            var serializer = new ProtobufSerializer(null);

            var exception = new ArgumentException("Test");
            var obj = new ResponseMessage { Exception = exception };
            var bytes = serializer.ToBinary(obj);

            var obj2 = (ResponseMessage)serializer.FromBinary(bytes, null);
            Assert.Equal(obj.Exception.GetType(), obj2.Exception.GetType());
        }
        public void TestSeriDeseri_ReplyMessageWithNothing()
        {
            var serializer = new ProtobufSerializer(null);

            var obj = new ResponseMessage
            {
                RequestId = 12345678,
            };

            var bytes = serializer.ToBinary(obj);

            var obj2 = (ResponseMessage)serializer.FromBinary(bytes, null);
            Assert.Equal(obj.RequestId, obj2.RequestId);
        }
        public void TestBuiltinException()
        {
            var serializer = new ProtobufSerializer(null);

            var exception = new ArgumentException("Test");
            var obj       = new ResponseMessage {
                Exception = exception
            };
            var bytes = serializer.ToBinary(obj);

            var obj2 = (ResponseMessage)serializer.FromBinary(bytes, null);

            Assert.Equal(obj.Exception.GetType(), obj2.Exception.GetType());
        }
        public void TestSourceSurrogate()
        {
            var serializer = new ProtobufSerializer(null);

            var obj = new ResponseMessage
            {
                ReturnPayload = new Source { Data = "Hello" }
            };

            var bytes = serializer.ToBinary(obj);

            var obj2 = (ResponseMessage)serializer.FromBinary(bytes, null);
            Assert.Equal(obj.ReturnPayload.Value, obj2.ReturnPayload.Value);
        }
示例#5
0
        public void TestSeriDeseri_ReplyMessageWithNothing()
        {
            var serializer = new ProtobufSerializer(null);

            var obj = new ResponseMessage
            {
                RequestId = 12345678,
            };

            var bytes = serializer.ToBinary(obj);

            var obj2 = (ResponseMessage)serializer.FromBinary(bytes, null);

            Assert.Equal(obj.RequestId, obj2.RequestId);
        }
        public void Test_Serialize_MessageContainingDefaultValues()
        {
            var serializer = new ProtobufSerializer(null);

            var msg = new IDefault_PayloadTable.CallWithDefault_Invoke { a = 2, b = 2, c = "Test" };
            var obj = new RequestMessage { InvokePayload = msg };

            var bytes = serializer.ToBinary(obj);
            var obj2 = (RequestMessage)serializer.FromBinary(bytes, null);
            var msg2 = (IDefault_PayloadTable.CallWithDefault_Invoke)obj2.InvokePayload;

            Assert.Equal(msg.a, msg2.a);
            Assert.Equal(msg.b, msg2.b);
            Assert.Equal(msg.c, msg2.c);
        }
        public void TestSurrogateForAddress()
        {
            var serializer = new ProtobufSerializer(null);

            var obj = new ResponseMessage
            {
                RequestId = 12345678,
                ReturnPayload = new AddressReturnMessage { v = Address.Parse("akka://system@host:1234") }
            };

            var bytes = serializer.ToBinary(obj);

            var obj2 = (ResponseMessage)serializer.FromBinary(bytes, null);
            Assert.Equal(obj.ReturnPayload.Value.ToString(), obj2.ReturnPayload.Value.ToString());
        }
        public void TestTypeAliasException()
        {
            var serializer = new ProtobufSerializer(null);

            var exception = new TestException { ErrorCode = 1000, ErrorDetail = "Test" };
            var obj = new ResponseMessage { Exception = exception };
            var bytes = serializer.ToBinary(obj);

            var obj2 = (ResponseMessage)serializer.FromBinary(bytes, null);
            Assert.Equal(obj.Exception.GetType(), obj2.Exception.GetType());

            var exception2 = (TestException)obj2.Exception;
            Assert.Equal(exception.ErrorCode, exception2.ErrorCode);
            Assert.Equal(exception.ErrorDetail, exception2.ErrorDetail);
        }
        public void TestSeriDeseri_RequestMessage()
        {
            var serializer = new ProtobufSerializer(null);

            var obj = new RequestMessage
            {
                RequestId = 12345678,
                InvokePayload = new TestInvokableMessage { a = "Hello", b = "World" }
            };

            var bytes = serializer.ToBinary(obj);

            var obj2 = (RequestMessage)serializer.FromBinary(bytes, null);
            Assert.Equal(obj.RequestId, obj2.RequestId);
            Assert.Equal(((TestInvokableMessage)obj.InvokePayload).a, ((TestInvokableMessage)obj2.InvokePayload).a);
            Assert.Equal(((TestInvokableMessage)obj.InvokePayload).b, ((TestInvokableMessage)obj2.InvokePayload).b);
        }
示例#10
0
        public void TestSeriDeseri_ReplyMessageWithException()
        {
            var serializer = new ProtobufSerializer(null);

            var obj = new ResponseMessage
            {
                RequestId = 12345678,
                Exception = new Exception("Test-Exception")
            };

            var bytes = serializer.ToBinary(obj);

            var obj2 = (ResponseMessage)serializer.FromBinary(bytes, null);

            Assert.Equal(obj.RequestId, obj2.RequestId);
            Assert.NotNull(obj2.Exception);
        }
        public void TestSurrogateDirectives()
        {
            var serializer = new ProtobufSerializer(null);

            var obj = new ResponseMessage
            {
                ReturnPayload = new Source2 {
                    Data = "Hello"
                }
            };

            var bytes = serializer.ToBinary(obj);

            var obj2 = (ResponseMessage)serializer.FromBinary(bytes, null);

            Assert.Equal(obj.ReturnPayload.Value, obj2.ReturnPayload.Value);
        }
        public void TestSurrogateForAddress()
        {
            var serializer = new ProtobufSerializer(null);

            var obj = new ResponseMessage
            {
                RequestId     = 12345678,
                ReturnPayload = new AddressReturnMessage {
                    v = Address.Parse("akka://system@host:1234")
                }
            };

            var bytes = serializer.ToBinary(obj);

            var obj2 = (ResponseMessage)serializer.FromBinary(bytes, null);

            Assert.Equal(obj.ReturnPayload.Value.ToString(), obj2.ReturnPayload.Value.ToString());
        }
示例#13
0
        public void TestSeriDeseri_ReplyWithResult()
        {
            var serializer = new ProtobufSerializer(null);

            var obj = new ResponseMessage
            {
                RequestId     = 12345678,
                ReturnPayload = new TestReturnMessage {
                    v = "HelloWorld"
                }
            };

            var bytes = serializer.ToBinary(obj);

            var obj2 = (ResponseMessage)serializer.FromBinary(bytes, typeof(TestReturnMessage));

            Assert.Equal(obj.RequestId, obj2.RequestId);
            Assert.Equal(((TestReturnMessage)obj.ReturnPayload).Value, ((TestReturnMessage)obj2.ReturnPayload).Value);
        }
        public void TestSurrogateForIActorRef()
        {
            var system     = ActorSystem.Create("Sys");
            var serializer = new ProtobufSerializer((ExtendedActorSystem)system);
            var actor      = system.ActorOf <DummyActor>("TestActor");

            var obj = new ResponseMessage
            {
                ReturnPayload = new ActorReturnMessage {
                    v = actor
                }
            };

            var bytes = serializer.ToBinary(obj);

            var obj2 = (ResponseMessage)serializer.FromBinary(bytes, null);

            Assert.Equal(obj.ReturnPayload.Value, obj2.ReturnPayload.Value);
        }
        public void Test_Serialize_MessageContainingDefaultValues()
        {
            var serializer = new ProtobufSerializer(null);

            var msg = new IDefault_PayloadTable.CallWithDefault_Invoke {
                a = 2, b = 2, c = "Test"
            };
            var obj = new RequestMessage {
                InvokePayload = msg
            };

            var bytes = serializer.ToBinary(obj);
            var obj2  = (RequestMessage)serializer.FromBinary(bytes, null);
            var msg2  = (IDefault_PayloadTable.CallWithDefault_Invoke)obj2.InvokePayload;

            Assert.Equal(msg.a, msg2.a);
            Assert.Equal(msg.b, msg2.b);
            Assert.Equal(msg.c, msg2.c);
        }
示例#16
0
        public void TestSeriDeseri_RequestMessage()
        {
            var serializer = new ProtobufSerializer(null);

            var obj = new RequestMessage
            {
                RequestId     = 12345678,
                InvokePayload = new TestInvokableMessage {
                    a = "Hello", b = "World"
                }
            };

            var bytes = serializer.ToBinary(obj);

            var obj2 = (RequestMessage)serializer.FromBinary(bytes, null);

            Assert.Equal(obj.RequestId, obj2.RequestId);
            Assert.Equal(((TestInvokableMessage)obj.InvokePayload).a, ((TestInvokableMessage)obj2.InvokePayload).a);
            Assert.Equal(((TestInvokableMessage)obj.InvokePayload).b, ((TestInvokableMessage)obj2.InvokePayload).b);
        }
示例#17
0
        public void TestSeriDeseri_NotificationMessage()
        {
            var serializer = new ProtobufSerializer(null);

            var obj = new NotificationMessage
            {
                ObserverId     = 10,
                NotificationId = 5,
                InvokePayload  = new TestNotificationMessage {
                    a = "Namaste"
                }
            };

            var bytes = serializer.ToBinary(obj);

            var obj2 = (NotificationMessage)serializer.FromBinary(bytes, null);

            Assert.Equal(obj.ObserverId, obj2.ObserverId);
            Assert.Equal(obj.NotificationId, obj2.NotificationId);
            Assert.Equal(((TestNotificationMessage)obj.InvokePayload).a, ((TestNotificationMessage)obj2.InvokePayload).a);
        }
        public void TestTypeAliasException()
        {
            var serializer = new ProtobufSerializer(null);

            var exception = new TestException {
                ErrorCode = 1000, ErrorDetail = "Test"
            };
            var obj = new ResponseMessage {
                Exception = exception
            };
            var bytes = serializer.ToBinary(obj);

            var obj2 = (ResponseMessage)serializer.FromBinary(bytes, null);

            Assert.Equal(obj.Exception.GetType(), obj2.Exception.GetType());

            var exception2 = (TestException)obj2.Exception;

            Assert.Equal(exception.ErrorCode, exception2.ErrorCode);
            Assert.Equal(exception.ErrorDetail, exception2.ErrorDetail);
        }
        public void TestSeriDeseri_NotificationMessage()
        {
            var serializer = new ProtobufSerializer(null);

            var obj = new NotificationMessage
            {
                ObserverId = 10,
                NotificationId = 5,
                InvokePayload = new TestNotificationMessage { a = "Namaste" }
            };

            var bytes = serializer.ToBinary(obj);

            var obj2 = (NotificationMessage)serializer.FromBinary(bytes, null);
            Assert.Equal(obj.ObserverId, obj2.ObserverId);
            Assert.Equal(obj.NotificationId, obj2.NotificationId);
            Assert.Equal(((TestNotificationMessage)obj.InvokePayload).a, ((TestNotificationMessage)obj2.InvokePayload).a);
        }
        public void TestSurrogateForIActorRef()
        {
            var system = ActorSystem.Create("Sys");
            var serializer = new ProtobufSerializer((ExtendedActorSystem)system);
            var actor = system.ActorOf<DummyActor>("TestActor");

            var obj = new ResponseMessage
            {
                ReturnPayload = new ActorReturnMessage { v = actor }
            };

            var bytes = serializer.ToBinary(obj);

            var obj2 = (ResponseMessage)serializer.FromBinary(bytes, null);
            Assert.Equal(obj.ReturnPayload.Value, obj2.ReturnPayload.Value);
        }
        public void TestSeriDeseri_ReplyWithResult()
        {
            var serializer = new ProtobufSerializer(null);

            var obj = new ResponseMessage
            {
                RequestId = 12345678,
                ReturnPayload = new TestReturnMessage { v = "HelloWorld" }
            };

            var bytes = serializer.ToBinary(obj);

            var obj2 = (ResponseMessage)serializer.FromBinary(bytes, typeof(TestReturnMessage));
            Assert.Equal(obj.RequestId, obj2.RequestId);
            Assert.Equal(((TestReturnMessage)obj.ReturnPayload).Value, ((TestReturnMessage)obj2.ReturnPayload).Value);
        }
        public void TestSeriDeseri_ReplyMessageWithException()
        {
            var serializer = new ProtobufSerializer(null);

            var obj = new ResponseMessage
            {
                RequestId = 12345678,
                Exception = new Exception("Test-Exception")
            };

            var bytes = serializer.ToBinary(obj);

            var obj2 = (ResponseMessage)serializer.FromBinary(bytes, null);
            Assert.Equal(obj.RequestId, obj2.RequestId);
            Assert.NotNull(obj2.Exception);
        }