Ejemplo n.º 1
0
        public void TestPackage()
        {
            ExtendProtocolSerialize.Enable();
            RPCPackage package = new RPCPackage {
                Count = 1, Method = "sdsad", GUID = "sdasjhnckjxzc0"
            };

            byte[]     bytes = ProtocolSerialize.Seralize(package);
            RPCPackage pack1 = ProtocolSerialize.Deseralize <RPCPackage>(bytes);

            Assert.AreEqual(package.Count, pack1.Count);
            Assert.AreEqual(package.Method, pack1.Method);
            Assert.AreEqual(package.GUID, pack1.GUID);
        }
Ejemplo n.º 2
0
        public void TestErrorData()
        {
            ExtendProtocolSerialize.Enable();
            byte[] bytes = new byte[] { 1, 2, 3, 4, 5, 6, 7 };
            ProtocolSerialize.compatibility = ProtocolSerialize.Compatibility.Strict;

            RPCPackage pack1 = ProtocolSerialize.Deseralize <RPCPackage>(bytes);

            Assert.IsTrue(pack1 == null || !pack1.Validity());
            ProtocolSerialize.compatibility = ProtocolSerialize.Compatibility.MostCompatible;

            RPCPackage pack11 = ProtocolSerialize.Deseralize <RPCPackage>(bytes);

            Assert.IsNotNull(pack11);
        }