public void Set(byte[] newContent) { if (newContent.Length > bufferSize) throw new InvalidOperationException(string.Format("New buffer content exeeds internal size. New content size: {0} bytes. Internal buffer size: {1} bytes.", newContent.Length, bufferSize)); Buffer.BlockCopy(newContent,0,ByteBuffer,0,newContent.Length); ContentLength = newContent.Length; }
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); }