Esempio n. 1
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);
        }
Esempio n. 2
0
        public void ObjectGraphAck_Basic()
        {
            ObjectGraphAck msg;

            msg = new ObjectGraphAck();
            Assert.IsNull(msg.Graph);
            Assert.AreEqual(Compress.Best, msg.Compress);

            msg = new ObjectGraphAck(10);
            Assert.AreEqual(10, msg.Graph);
            Assert.AreEqual(Compress.Best, msg.Compress);

            msg = new ObjectGraphAck("hello world", Compress.Always);
            Assert.AreEqual("hello world", msg.Graph);
            Assert.AreEqual(Compress.Always, msg.Compress);

            msg = new ObjectGraphAck(new TimeoutException("timeout"));
            Assert.AreEqual("timeout", msg.Exception);
        }