Ejemplo n.º 1
0
        public void TestBytesConvert_StspOperationHeader()
        {
            //result should be:[0,0,0,0,1,0,0,0]
            var result = StreamConvertor.BuildOperationBytes(StspOperation.StspOperation_ClientRequestDescription);

            Assert.IsTrue(BufferHelper.isBytesSame(result, Bytes_ClientRequestDescription));
        }
Ejemplo n.º 2
0
        public void TestGetBuffer()
        {
            clearPacket();

            packet.AddBuffer(data1);
            Assert.IsTrue(BufferHelper.isBytesSame(data1, packet.GetBuffer(data1.Length)));

            packet.AddBuffer(data2);
            Assert.IsTrue(BufferHelper.isBytesSame(data1, packet.GetBuffer(data1.Length)));

            var allBuffers = BufferHelper.Combine(data1, data2);

            Assert.IsTrue(BufferHelper.isBytesSame(allBuffers, packet.GetBuffer(data1.Length + data2.Length)));
        }
Ejemplo n.º 3
0
        public void TestTakeBuffer()
        {
            clearPacket();

            packet.AddBuffer(data1);
            packet.AddBuffer(data2);
            packet.AddBuffer(data3);
            packet.AddBuffer(data4);

            Assert.AreEqual(data1.Length + data2.Length + data3.Length + data4.Length, packet.GetLength());

            Assert.IsTrue(BufferHelper.isBytesSame(data1, packet.TakeBuffer(data1.Length)));
            Assert.AreEqual(data2.Length + data3.Length + data4.Length, packet.GetLength());

            Assert.IsTrue(BufferHelper.isBytesSame(data2, packet.TakeBuffer(data2.Length)));
            Assert.AreEqual(data3.Length + data4.Length, packet.GetLength());

            Assert.IsTrue(BufferHelper.isBytesSame(data3, packet.TakeBuffer(data3.Length)));
            Assert.AreEqual(data4.Length, packet.GetLength());

            Assert.IsTrue(BufferHelper.isBytesSame(data4, packet.TakeBuffer(data4.Length)));
            Assert.AreEqual(0, packet.GetLength());
        }