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))); }
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()); }