Example #1
0
        // Verify msg type: GC_Chat_Msg
        private static void Verify_GC_Chat_Msg()
        {
            GC_Chat_Msg stSrc = new GC_Chat_Msg();

            // Make object rand
            byte[]        src_bytes = stSrc.ToBytes();
            MBinaryReader mbr       = new MBinaryReader(src_bytes);
            GC_Chat_Msg   stDst     = new GC_Chat_Msg();

            stDst.msg_len = mbr.ReadUInt16();
            stDst.msg_id  = mbr.ReadUInt16();
            stDst.FromBytes(mbr);
            // Verify object content
            if (stDst.msg_len != GC_Chat_Msg.MSG_LEN)
            {
                Console.WriteLine("Failed to verify field: msg_len");
            }
            if (stDst.msg_id != GC_Chat_Msg.MSG_ID)
            {
                Console.WriteLine("Failed to verify field: msg_id");
            }
            // Compare object by bytes
            byte[] dst_bytes = stDst.ToBytes();
            if (dst_bytes.Length != src_bytes.Length)
            {
                Console.WriteLine("Failed to verify field: GC_Chat_Msg by bytes length");
            }
            for (int byte_index = 0; byte_index < dst_bytes.Length; ++byte_index)
            {
                if (src_bytes[byte_index] != dst_bytes[byte_index])
                {
                    Console.WriteLine("Failed to verify field: GC_Chat_Msg by bytes length");
                }
            }
        }