public void ShouldSetBufferLength() { var byteArray = new RingbufferByteArray(); var source = new byte[] { 1,2,3,4,5,6,7,8,9,10 }; Assert.AreEqual(0, byteArray.ContentLength); byteArray.Set(source); Assert.AreEqual(10, byteArray.ContentLength); }
public void ShouldSetContent() { var byteArray = new RingbufferByteArray(); var source = new byte[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 }; byte[] target = new byte[512]; byteArray.Set(source); byteArray.GetContent(ref target); ArrayComparer.AreEqual(byteArray.ByteBuffer, target); }
public void SerializeDeserializeTest() { var serializer = new ProtobufSerializer(); var byteArray = new RingbufferByteArray(); var item = new ServerToClientMessage(); item.Message = "hello"; item.MessageType = ServerToClientMessageTypeEnum.LimitOrderAccepted; byteArray.Set(serializer.Serialize(item)); byte[] target = new byte[512]; byteArray.GetContent(ref target); var deserialized = serializer.Deserialize<ServerToClientMessage>(target.Take(byteArray.ContentLength).ToArray()); Assert.IsNotNull(deserialized); Assert.AreEqual("hello", deserialized.Message); Assert.AreEqual(ServerToClientMessageTypeEnum.LimitOrderAccepted, deserialized.MessageType); }