Example #1
0
        public void ReliableTransferMsg_Basic()
        {
            EnhancedStream      es = new EnhancedMemoryStream();
            ReliableTransferMsg msgIn, msgOut;
            Guid id = Helper.NewGuid();

            Msg.ClearTypes();
            Msg.LoadTypes(Assembly.GetExecutingAssembly());

            msgOut            = new ReliableTransferMsg(ReliableTransferMsg.ErrorCmd);
            msgOut.Direction  = TransferDirection.Download;
            msgOut.TransferID = id;
            msgOut.Args       = "Hello";
            msgOut.BlockData  = new byte[] { 0, 1, 2, 3, 4 };
            msgOut.BlockIndex = 10;
            msgOut.BlockSize  = 1024;
            msgOut.Exception  = "Error";

            Msg.Save(es, msgOut);
            es.Position = 0;
            msgIn       = (ReliableTransferMsg)Msg.Load(es);

            Assert.IsNotNull(msgIn);
            Assert.AreEqual(TransferDirection.Download, msgIn.Direction);
            Assert.AreEqual(id, msgIn.TransferID);
            Assert.AreEqual("Hello", msgIn.Args);
            CollectionAssert.AreEqual(new byte[] { 0, 1, 2, 3, 4 }, msgIn.BlockData);
            Assert.AreEqual(10, msgIn.BlockIndex);
            Assert.AreEqual(1024, msgIn.BlockSize);
            Assert.AreEqual("Error", msgIn.Exception);
        }
Example #2
0
        public void Msg_Serialize_TestMsg()
        {
            _TestMsg2      msgIn, msgOut;
            EnhancedStream es = new EnhancedMemoryStream();

            Msg.ClearTypes();
            Msg.LoadTypes(Assembly.GetExecutingAssembly());

            msgOut             = new _TestMsg2();
            msgOut.BoolValue   = false;
            msgOut.ByteValue   = 0xAA;
            msgOut.BytesValue  = new byte[] { 0, 1, 2, 3 };
            msgOut.FloatValue  = 10.77F;
            msgOut.Int16Value  = 32000;
            msgOut.Int32Value  = 100000;
            msgOut.Int64Value  = 8000000000;
            msgOut.StringValue = "Hello World!";
            Msg.Save(es, msgOut);

            es.Seek(0, SeekOrigin.Begin);
            msgIn = (_TestMsg2)Msg.Load(es);
            Assert.AreEqual(msgOut.BoolValue, msgIn.BoolValue);
            Assert.AreEqual(msgOut.ByteValue, msgIn.ByteValue);
            CollectionAssert.AreEqual(msgOut.BytesValue, msgIn.BytesValue);
            Assert.AreEqual(msgOut.FloatValue, msgIn.FloatValue);
            Assert.AreEqual(msgOut.Int16Value, msgIn.Int16Value);
            Assert.AreEqual(msgOut.Int32Value, msgIn.Int32Value);
            Assert.AreEqual(msgOut.Int64Value, msgIn.Int64Value);
            Assert.AreEqual(msgOut.StringValue, msgIn.StringValue);

            Assert.AreEqual(0, msgIn._Version);
            Assert.IsNull(msgIn._ToEP);
            Assert.IsNull(msgIn._FromEP);
        }
Example #3
0
        public void ClusterMemberMsg_Basic()
        {
            EnhancedStream   es = new EnhancedMemoryStream();
            ClusterMemberMsg msgIn, msgOut;

            Msg.ClearTypes();
            Msg.LoadTypes(Assembly.GetExecutingAssembly());

            msgOut = new ClusterMemberMsg("logical://test", "my command");
            msgOut.ProtocolCaps = unchecked ((ClusterMemberProtocolCaps)0xFFFFFFFF);
            msgOut.Flags        = (ClusterMemberMsgFlag)0x7FFFFFFF;
            msgOut._Set("hello", "world!");
            msgOut._Data = new byte[] { 0, 1, 2, 3, 4, 5 };

            Msg.Save(es, msgOut);
            es.Position = 0;
            msgIn       = (ClusterMemberMsg)Msg.Load(es);

            Assert.IsNotNull(msgIn);
            Assert.AreEqual("logical://test", (string)msgIn.SenderEP);
            Assert.AreEqual(unchecked ((ClusterMemberProtocolCaps)0xFFFFFFFF), msgIn.ProtocolCaps);
            Assert.AreEqual((ClusterMemberMsgFlag)0x7FFFFFFF, msgIn.Flags);
            Assert.AreEqual("my command", msgIn.Command);
            Assert.AreEqual("world!", msgIn["hello"]);
            CollectionAssert.AreEqual(new byte[] { 0, 1, 2, 3, 4, 5 }, msgOut._Data);
        }
Example #4
0
        public void BlobPropertyMsg_SerializeBase()
        {
            _BlobPropMsg         msgOut, msgIn;
            EnhancedMemoryStream ms = new EnhancedMemoryStream();

            Msg.ClearTypes();
            Msg.LoadTypes(Assembly.GetExecutingAssembly());

            msgOut = new _BlobPropMsg();
            msgOut._Set("string", "hello");
            msgOut._Set("bool", true);
            msgOut._Set("int", 10);
            msgOut._Set("timespan", new TimeSpan(0, 0, 0, 0, 55));
            msgOut._Set("endpoint", new IPEndPoint(IPAddress.Parse("127.0.0.1"), 56));
            msgOut._Set("bytes", new byte[] { 5, 6, 7, 8 });
            msgOut._Data = new byte[] { 0, 1, 2 };
            msgOut.Value = "foobar";

            Msg.Save(ms, msgOut);

            ms.Seek(0, SeekOrigin.Begin);
            msgIn = (_BlobPropMsg)Msg.Load(ms);

            Assert.AreEqual(msgOut["string"], msgIn["string"]);
            Assert.AreEqual(msgOut["bool"], msgIn["bool"]);
            Assert.AreEqual(msgOut["int"], msgIn["int"]);
            Assert.AreEqual(msgOut["timespan"], msgIn["timespan"]);
            Assert.AreEqual(msgOut["endpoint"], msgIn["endpoint"]);
            Assert.AreEqual(msgOut["bytes"], msgIn["bytes"]);
            CollectionAssert.AreEqual(msgOut._Data, msgIn._Data);
            Assert.AreEqual("foobar", msgIn.Value);
        }
Example #5
0
        public void Msg_Serialize_BaseMsg()
        {
            Msg            msg;
            EnhancedStream es = new EnhancedMemoryStream();

            Msg.ClearTypes();
            Msg.LoadTypes(Assembly.GetExecutingAssembly());

            msg          = new Msg();
            msg._Version = 77;
            msg._Flags  |= MsgFlag.Broadcast;
            es.SetLength(0);
            Msg.Save(es, msg);

            es.Seek(0, SeekOrigin.Begin);
            msg = (Msg)Msg.Load(es);
            Assert.IsNotNull(msg);
            Assert.AreEqual(77, msg._Version);
            Assert.AreEqual(MsgFlag.Broadcast, msg._Flags);

            msg          = new Msg();
            msg._Version = 77;
            msg._Flags  |= MsgFlag.Broadcast | MsgFlag.OpenSession;
            es.SetLength(0);
            Msg.Save(es, msg);

            es.Seek(0, SeekOrigin.Begin);
            msg = (Msg)Msg.Load(es);
            Assert.IsNotNull(msg);
            Assert.AreEqual(77, msg._Version);
            Assert.AreEqual(MsgFlag.Broadcast | MsgFlag.OpenSession, msg._Flags);
        }
Example #6
0
        public void Msg_Serialize_Guids()
        {
            Msg            msgIn, msgOut;
            EnhancedStream es = new EnhancedMemoryStream();

            Msg.ClearTypes();
            Msg.LoadTypes(Assembly.GetExecutingAssembly());

            msgOut = new Msg();
            Assert.AreEqual(Guid.Empty, msgOut._MsgID);
            Assert.AreEqual(Guid.Empty, msgOut._SessionID);

            Msg.Save(es, msgOut);
            es.Seek(0, SeekOrigin.Begin);
            msgIn = Msg.Load(es);

            Assert.AreEqual(Guid.Empty, msgIn._MsgID);
            Assert.AreEqual(Guid.Empty, msgIn._SessionID);

            msgOut._MsgID     = Helper.NewGuid();
            msgOut._SessionID = Helper.NewGuid();

            es.SetLength(0);
            Msg.Save(es, msgOut);
            es.Seek(0, SeekOrigin.Begin);
            msgIn = Msg.Load(es);

            Assert.AreEqual(msgOut._MsgID, msgIn._MsgID);
            Assert.AreEqual(msgOut._SessionID, msgIn._SessionID);
        }
Example #7
0
        public void Msg_Serialize_SecurityToken()
        {
            Msg            msgIn, msgOut;
            EnhancedStream es = new EnhancedMemoryStream();

            Msg.ClearTypes();
            Msg.LoadTypes(Assembly.GetExecutingAssembly());

            msgOut = new Msg();
            Assert.IsNull(msgOut._SecurityToken);

            Msg.Save(es, msgOut);
            es.Seek(0, SeekOrigin.Begin);
            msgIn = Msg.Load(es);

            Assert.IsNull(msgOut._SecurityToken);

            msgOut._SecurityToken = new byte[] { 0, 1, 2, 3, 4 };

            es.SetLength(0);
            Msg.Save(es, msgOut);
            es.Seek(0, SeekOrigin.Begin);
            msgIn = Msg.Load(es);

            CollectionAssert.AreEqual(msgOut._SecurityToken, msgIn._SecurityToken);
        }
Example #8
0
        public void Msg_Clone_HubAdvertiseMsg()
        {
            HubAdvertiseMsg msgIn, msgOut;

            Msg.ClearTypes();
            Msg.LoadTypes(Assembly.GetExecutingAssembly());

            msgOut         = new HubAdvertiseMsg(MsgEP.Parse("physical://root.com:80/hub/leaf"), "appname", "appdescription", new MsgRouterInfo(new Version(1000, 0)), Helper.NewGuid());
            msgOut._FromEP = MsgEP.Parse("physical://root.com:80/hub/leaf?c=tcp://1.2.3.4:57");
            Assert.AreEqual(Guid.Empty, msgOut._MsgID);

            msgIn = (HubAdvertiseMsg)msgOut.Clone();

            Assert.AreEqual("physical://root.com:80/hub/leaf", msgIn.HubEP.ToString());
            Assert.AreEqual("appname", msgIn.AppName);
            Assert.AreEqual("appdescription", msgIn.AppDescription);
            Assert.AreEqual(new Version(1000, 0), msgIn.RouterInfo.ProtocolVersion);
            Assert.AreEqual(IPAddress.Parse("1.2.3.4"), msgIn.IPAddress);
            Assert.AreEqual(57, msgIn.TcpPort);
            Assert.AreEqual(msgOut.LogicalEndpointSetID, msgIn.LogicalEndpointSetID);
            Assert.AreEqual(Guid.Empty, msgIn._MsgID);

            msgOut._MsgID = Helper.NewGuid();
            msgIn         = (HubAdvertiseMsg)msgOut.Clone();

            Assert.AreNotEqual(Guid.Empty, msgIn._MsgID);

            TestBaseCloning(msgOut);
        }
Example #9
0
        public void PropertyMsg_Serialize()
        {
            PropertyMsg          msgOut, msgIn;
            EnhancedMemoryStream ms = new EnhancedMemoryStream();

            Msg.ClearTypes();
            Msg.LoadTypes(Assembly.GetExecutingAssembly());

            msgOut = new PropertyMsg();
            msgOut._Set("string", "hello");
            msgOut._Set("bool", true);
            msgOut._Set("int", 10);
            msgOut._Set("timespan", new TimeSpan(0, 0, 0, 0, 55));
            msgOut._Set("endpoint", new IPEndPoint(IPAddress.Parse("127.0.0.1"), 56));
            msgOut._Set("bytes", new byte[] { 5, 6, 7, 8 });
            msgOut._Set("address", IPAddress.Parse("10.20.30.40"));

            Msg.Save(ms, msgOut);

            ms.Seek(0, SeekOrigin.Begin);
            msgIn = (PropertyMsg)Msg.Load(ms);

            Assert.AreEqual(msgOut["string"], msgIn["string"]);
            Assert.AreEqual(msgOut["bool"], msgIn["bool"]);
            Assert.AreEqual(msgOut["int"], msgIn["int"]);
            Assert.AreEqual(msgOut["timespan"], msgIn["timespan"]);
            Assert.AreEqual(msgOut["endpoint"], msgIn["endpoint"]);
            Assert.AreEqual(msgOut["bytes"], msgIn["bytes"]);
            Assert.AreEqual(msgOut["address"], msgIn["address"]);
        }
Example #10
0
        public void Msg_Clone_RouteAdvertiseMsg()
        {
            RouterAdvertiseMsg msgIn, msgOut;

            Msg.ClearTypes();
            Msg.LoadTypes(Assembly.GetExecutingAssembly());

            msgOut         = new RouterAdvertiseMsg(MsgEP.Parse("physical://root.com:80/hub/leaf"), "appname", "appdescription", new MsgRouterInfo(new Version(1000, 0)), 10, 20, Helper.NewGuid(), false, true);
            msgOut._FromEP = MsgEP.Parse("physical://root.com:80/hub/leaf?c=mcast://1.2.3.4:57");
            msgIn          = (RouterAdvertiseMsg)msgOut.Clone();

            Assert.AreEqual("physical://root.com:80/hub/leaf", msgIn.RouterEP.ToString());
            Assert.AreEqual("appname", msgIn.AppName);
            Assert.AreEqual("appdescription", msgIn.AppDescription);
            Assert.AreEqual(new Version(1000, 0), msgIn.RouterInfo.ProtocolVersion);
            Assert.AreEqual(IPAddress.Parse("1.2.3.4"), msgIn.IPAddress);
            Assert.AreEqual(10, msgIn.UdpPort);
            Assert.AreEqual(20, msgIn.TcpPort);
            Assert.AreEqual(msgOut.LogicalEndpointSetID, msgIn.LogicalEndpointSetID);
            Assert.IsFalse(msgIn.ReplyAdvertise);
            Assert.IsTrue(msgIn.DiscoverLogical);
            Assert.IsTrue(msgIn.RouterInfo.IsP2P);

            TestBaseCloning(msgOut);
        }
Example #11
0
        public void ReliableMessengerMsgs_DeliveryMsg_Serialize()
        {
            DeliveryMsg    msgIn, msgOut;
            EnhancedStream es  = new EnhancedMemoryStream();
            DateTime       now = Helper.UtcNowRounded;
            Guid           id  = Helper.NewGuid();
            PropertyMsg    query;
            PropertyMsg    response;

            Msg.ClearTypes();
            Msg.LoadTypes(Assembly.GetExecutingAssembly());

            query           = new PropertyMsg();
            query["hello"]  = "world";
            response        = new PropertyMsg();
            response["foo"] = "bar";

            msgOut = new DeliveryMsg(DeliveryOperation.Attempt, now, "logical://foo", "logical://bar", query, id,
                                     "clusterInfo", "clusterParam", new TimeoutException("Timeout"), response);
            Msg.Save(es, msgOut);
            es.Seek(0, SeekOrigin.Begin);
            msgIn = (DeliveryMsg)Msg.Load(es);

            Assert.IsNotNull(msgIn);
            Assert.AreEqual(DeliveryOperation.Attempt, msgIn.Operation);
            Assert.AreEqual(now, msgIn.Timestamp);
            Assert.AreEqual(MsgEP.Parse("logical://foo"), msgIn.TargetEP);
            Assert.AreEqual(MsgEP.Parse("logical://bar"), msgIn.ConfirmEP);
            Assert.IsInstanceOfType(msgIn.Query, typeof(PropertyMsg));
            Assert.AreEqual("world", ((PropertyMsg)msgIn.Query)["hello"]);
            Assert.AreEqual(id, msgIn.TopologyID);
            Assert.AreEqual("clusterInfo", msgIn.TopologyInfo);
            Assert.AreEqual("clusterParam", msgIn.TopologyParam);
            Assert.IsInstanceOfType(msgIn.Exception, typeof(TimeoutException));
            Assert.AreEqual("Timeout", msgIn.Exception.Message);
            Assert.IsInstanceOfType(msgIn.Response, typeof(PropertyMsg));
            Assert.AreEqual("bar", ((PropertyMsg)msgIn.Response)["foo"]);

            msgOut = new DeliveryMsg(DeliveryOperation.Confirmation, now, "logical://foo", null, query, id,
                                     null, null, new ArgumentException("Test"), null);
            es.SetLength(0);
            Msg.Save(es, msgOut);
            es.Seek(0, SeekOrigin.Begin);
            msgIn = (DeliveryMsg)Msg.Load(es);

            Assert.IsNotNull(msgIn);
            Assert.AreEqual(DeliveryOperation.Confirmation, msgIn.Operation);
            Assert.AreEqual(now, msgIn.Timestamp);
            Assert.AreEqual(MsgEP.Parse("logical://foo"), msgIn.TargetEP);
            Assert.IsNull(msgIn.ConfirmEP);
            Assert.IsInstanceOfType(msgIn.Query, typeof(PropertyMsg));
            Assert.AreEqual("world", ((PropertyMsg)msgIn.Query)["hello"]);
            Assert.AreEqual(id, msgIn.TopologyID);
            Assert.IsNull(msgIn.TopologyInfo);
            Assert.IsNull(msgIn.TopologyParam);
            Assert.IsInstanceOfType(msgIn.Exception, typeof(SessionException));
            Assert.AreEqual("Test", msgIn.Exception.Message);
            Assert.IsNull(msgIn.Response);
        }
Example #12
0
        public void Msg_Map_NoGetTypeID()
        {
            System.Type type;

            Msg.ClearTypes();
            Msg.LoadTypes(Assembly.GetExecutingAssembly());

            type = Msg.MapTypeID("LillTek.Messaging.Test.Messages._TestMsg1");
            Assert.AreEqual(typeof(_TestMsg1), type);
        }
Example #13
0
        public void Msg_Map_NoType()
        {
            System.Type type;

            Msg.ClearTypes();
            Msg.LoadTypes(Assembly.GetExecutingAssembly());

            type = Msg.MapTypeID("___foo___");
            Assert.IsNull(type);
        }
Example #14
0
        public void Msg_Map_BaseMsg()
        {
            System.Type type;

            Msg.ClearTypes();
            Msg.LoadTypes(Assembly.GetExecutingAssembly());

            type = Msg.MapTypeID(typeof(Msg).FullName);
            Assert.AreEqual(typeof(Msg), type);
        }
Example #15
0
        public void Msg_Map_Normal()
        {
            System.Type type;

            Msg.ClearTypes();
            Msg.LoadTypes(Assembly.GetExecutingAssembly());

            type = Msg.MapTypeID(_TestMsg2.GetTypeID());
            Assert.AreEqual(typeof(_TestMsg2), type);
        }
Example #16
0
        public void StopRouters()
        {
            Msg.ClearTypes();

            g1r1.Stop();
            g1r2.Stop();
            g1r3.Stop();
            g2r1.Stop();
            g2r2.Stop();
        }
Example #17
0
        public void ObjectGraphAck_Serialize()
        {
            ObjectGraphAck       msgOut, msgIn;
            EnhancedMemoryStream ms = new EnhancedMemoryStream();

            Msg.ClearTypes();
            Msg.LoadTypes(Assembly.GetExecutingAssembly());

            msgOut = new ObjectGraphAck("hello world", Compress.Always);

            Msg.Save(ms, msgOut);
            ms.Seek(0, SeekOrigin.Begin);
            msgIn = (ObjectGraphAck)Msg.Load(ms);

            Assert.AreEqual("hello world", msgIn.Graph);

            //-----------------------------------

            ms.SetLength(0);

            msgOut = new ObjectGraphAck(new string[] { "a", "b", "c" }, Compress.Always);

            Msg.Save(ms, msgOut);
            ms.Seek(0, SeekOrigin.Begin);
            msgIn = (ObjectGraphAck)Msg.Load(ms);

            CollectionAssert.AreEqual(new string[] { "a", "b", "c" }, (string[])msgIn.Graph);

            //-----------------------------------

            ms.SetLength(0);

            msgOut = new ObjectGraphAck(new TimeoutException("timeout"));

            Msg.Save(ms, msgOut);
            ms.Seek(0, SeekOrigin.Begin);
            msgIn = (ObjectGraphAck)Msg.Load(ms);

            Assert.AreEqual("timeout", msgIn.Exception);

            //-----------------------------------

            ms.SetLength(0);

            msgOut = new ObjectGraphAck(null, Compress.Always);

            Msg.Save(ms, msgOut);
            ms.Seek(0, SeekOrigin.Begin);
            msgIn = (ObjectGraphAck)Msg.Load(ms);

            Assert.IsNull(msgIn.Graph);
        }
Example #18
0
        public void ReliableMessengerMsgs_DeliveryAck_Clone()
        {
            DeliveryAck msgIn, msgOut;

            Msg.ClearTypes();
            Msg.LoadTypes(Assembly.GetExecutingAssembly());

            msgOut = new DeliveryAck();
            msgIn  = (DeliveryAck)msgOut.Clone();
            Assert.IsNotNull(msgIn);

            TestBaseCloning(msgOut);
        }
Example #19
0
        public void Msg_Clone_RouterStopMsg()
        {
            RouterStopMsg msgIn, msgOut;

            Msg.ClearTypes();
            Msg.LoadTypes(Assembly.GetExecutingAssembly());

            msgOut = new RouterStopMsg(MsgEP.Parse("physical://root.com:80/hub/leaf"));
            msgIn  = (RouterStopMsg)msgOut.Clone();

            Assert.AreEqual("physical://root.com:80/hub/leaf", msgIn.RouterEP.ToString());

            TestBaseCloning(msgOut);
        }
Example #20
0
        public void ReliableMessengerMsgs_DeliveryAck_Serialize()
        {
            DeliveryAck    msgIn, msgOut;
            EnhancedStream es = new EnhancedMemoryStream();

            Msg.ClearTypes();
            Msg.LoadTypes(Assembly.GetExecutingAssembly());

            msgOut = new DeliveryAck();

            Msg.Save(es, msgOut);
            es.Seek(0, SeekOrigin.Begin);
            msgIn = (DeliveryAck)Msg.Load(es);
            Assert.IsNotNull(msgIn);
        }
Example #21
0
        public void Msg_Clone_HubSettingsMsg()
        {
            HubSettingsMsg msgIn, msgOut;

            Msg.ClearTypes();
            Msg.LoadTypes(Assembly.GetExecutingAssembly());

            msgOut = new HubSettingsMsg(Helper.NewGuid(), TimeSpan.FromSeconds(100));
            msgIn  = (HubSettingsMsg)msgOut.Clone();

            Assert.AreEqual(TimeSpan.FromSeconds(100), msgIn.KeepAliveTime);
            Assert.AreEqual(msgOut.LogicalEndpointSetID, msgIn.LogicalEndpointSetID);

            TestBaseCloning(msgOut);
        }
Example #22
0
        public void Msg_Clone_SessionKeepAliveMsg()
        {
            SessionKeepAliveMsg msgIn, msgOut;

            Msg.ClearTypes();
            Msg.LoadTypes(Assembly.GetExecutingAssembly());

            msgOut = new SessionKeepAliveMsg(TimeSpan.FromMinutes(77));
            msgIn  = (SessionKeepAliveMsg)msgOut.Clone();

            Assert.IsNotNull(msgIn);
            Assert.AreEqual(msgOut.SessionTTL, msgIn.SessionTTL);

            TestBaseCloning(msgOut);
        }
Example #23
0
        public void Msg_Clone_DeadRouterMsg()
        {
            DeadRouterMsg msgIn, msgOut;

            Msg.ClearTypes();
            Msg.LoadTypes(Assembly.GetExecutingAssembly());

            msgOut = new DeadRouterMsg("physical://root/hub/leaf", Helper.NewGuid());
            msgIn  = (DeadRouterMsg)msgOut.Clone();

            Assert.AreEqual(msgOut.RouterEP, msgIn.RouterEP);
            Assert.AreEqual(msgOut.LogicalEndpointSetID, msgIn.LogicalEndpointSetID);

            TestBaseCloning(msgOut);
        }
Example #24
0
        public void Msg_Clone_ReceiptMsg()
        {
            ReceiptMsg msgIn, msgOut;

            Msg.ClearTypes();
            Msg.LoadTypes(Assembly.GetExecutingAssembly());

            msgOut = new ReceiptMsg(Helper.NewGuid());
            msgIn  = (ReceiptMsg)msgOut.Clone();

            Assert.IsNotNull(msgIn);
            Assert.AreEqual(msgOut.ReceiptID, msgIn.ReceiptID);

            TestBaseCloning(msgOut);
        }
Example #25
0
        public void Msg_Serialize_TTL()
        {
            Msg            msgIn, msgOut;
            EnhancedStream es = new EnhancedMemoryStream();

            Msg.ClearTypes();
            Msg.LoadTypes(Assembly.GetExecutingAssembly());

            msgOut      = new Msg();
            msgOut._TTL = 50;
            Msg.Save(es, msgOut);

            es.Seek(0, SeekOrigin.Begin);
            msgIn = Msg.Load(es);
            Assert.AreEqual(50, msgIn._TTL);
        }
Example #26
0
        public void Msg_Serialize_RouterStopMsg()
        {
            RouterStopMsg  msgIn, msgOut;
            EnhancedStream es = new EnhancedMemoryStream();

            Msg.ClearTypes();
            Msg.LoadTypes(Assembly.GetExecutingAssembly());

            msgOut = new RouterStopMsg(MsgEP.Parse("physical://root.com:80/hub/leaf"));

            Msg.Save(es, msgOut);
            es.Seek(0, SeekOrigin.Begin);
            msgIn = (RouterStopMsg)Msg.Load(es);

            Assert.AreEqual("physical://root.com:80/hub/leaf", msgIn.RouterEP.ToString());
        }
Example #27
0
        public void Msg_Serialize_SessionKeepAliveMsg()
        {
            SessionKeepAliveMsg msgIn, msgOut;
            EnhancedStream      es = new EnhancedMemoryStream();

            Msg.ClearTypes();
            Msg.LoadTypes(Assembly.GetExecutingAssembly());

            msgOut = new SessionKeepAliveMsg(TimeSpan.FromMinutes(77));

            Msg.Save(es, msgOut);
            es.Seek(0, SeekOrigin.Begin);
            msgIn = (SessionKeepAliveMsg)Msg.Load(es);

            Assert.IsNotNull(msgIn);
            Assert.AreEqual(msgOut.SessionTTL, msgIn.SessionTTL);
        }
Example #28
0
        public void Msg_Serialize_ReceiptMsg()
        {
            ReceiptMsg     msgIn, msgOut;
            EnhancedStream es = new EnhancedMemoryStream();

            Msg.ClearTypes();
            Msg.LoadTypes(Assembly.GetExecutingAssembly());

            msgOut = new ReceiptMsg(Helper.NewGuid());

            Msg.Save(es, msgOut);
            es.Seek(0, SeekOrigin.Begin);
            msgIn = (ReceiptMsg)Msg.Load(es);

            Assert.IsNotNull(msgIn);
            Assert.AreEqual(msgOut.ReceiptID, msgIn.ReceiptID);
        }
Example #29
0
        public void Msg_Clone_TcpInitMsg()
        {
            TcpInitMsg msg;

            Msg.ClearTypes();
            Msg.LoadTypes(Assembly.GetExecutingAssembly());

            msg = new TcpInitMsg("physical://root/hub/leaf", new MsgRouterInfo(new Version(1000, 0)), true, 77);
            msg = (TcpInitMsg)msg.Clone();
            Assert.AreEqual(new MsgEP("physical://root/hub/leaf"), msg.RouterEP);
            Assert.AreEqual(new Version(1000, 0), msg.RouterInfo.ProtocolVersion);
            Assert.IsTrue(msg.IsUplink);
            Assert.IsTrue(msg.RouterInfo.IsP2P);
            Assert.AreEqual(77, msg.ListenPort);

            TestBaseCloning(msg);
        }
Example #30
0
        public void Msg_Serialize_HubSettingsMsg()
        {
            HubSettingsMsg msgIn, msgOut;
            EnhancedStream es = new EnhancedMemoryStream();

            Msg.ClearTypes();
            Msg.LoadTypes(Assembly.GetExecutingAssembly());

            msgOut = new HubSettingsMsg(Helper.NewGuid(), TimeSpan.FromSeconds(100));

            Msg.Save(es, msgOut);
            es.Seek(0, SeekOrigin.Begin);
            msgIn = (HubSettingsMsg)Msg.Load(es);

            Assert.AreEqual(TimeSpan.FromSeconds(100), msgIn.KeepAliveTime);
            Assert.AreEqual(msgOut.LogicalEndpointSetID, msgIn.LogicalEndpointSetID);
        }