Esempio n. 1
0
        public static void TestThrift2365()
        {
            var rnd = new Random();

            for (var len = 0; len < 10; ++len)
            {
                byte[] dataWritten = new byte[len];
                rnd.NextBytes(dataWritten);

                Stream     stm   = new MemoryStream();
                TTransport trans = new TStreamTransport(null, stm);
                TProtocol  prot  = new TJSONProtocol(trans);
                prot.WriteBinary(dataWritten);

                stm.Position = 0;
                trans        = new TStreamTransport(stm, null);
                prot         = new TJSONProtocol(trans);
                byte[] dataRead = prot.ReadBinary();

                Debug.Assert(dataRead.Length == dataWritten.Length);
                for (var i = 0; i < dataRead.Length; ++i)
                {
                    Debug.Assert(dataRead[i] == dataWritten[i]);
                }
            }
        }
Esempio n. 2
0
        public void TestThrift2365()
        {
            var rnd = new Random();

            for (var len = 0; len < 10; ++len)
            {
                var dataWritten = new byte[len];
                rnd.NextBytes(dataWritten);

                Stream     stm   = new MemoryStream();
                TTransport trans = new TStreamTransport(null, stm);
                TProtocol  prot  = new TJSONProtocol(trans);
                prot.WriteBinary(dataWritten);

                stm.Position = 0;
                trans        = new TStreamTransport(stm, null);
                prot         = new TJSONProtocol(trans);
                byte[] dataRead = prot.ReadBinary();

                CollectionAssert.AreEqual(dataWritten, dataRead);
            }
        }