public void Write_UpdatesBuffer(int shadowBufferSize, int repCount) { int totBytes = repCount * shadowBufferSize; var config = GetConfig(shadowBufferSize, delayedWriter: true); byte[] sourceBuffer = Enumerable.Range(1, totBytes).Select(f => (byte)f).ToArray(); byte[] destBuffer = new byte[totBytes]; IWriter writer = new DelayedWriter(new MemoryStream(destBuffer), config); for (int ix = 0, f = 0; f < repCount; ix += shadowBufferSize, f++) { using (ShadowBufferData buf = writer.RequestBuffer()) { buf.byteCount = shadowBufferSize; Buffer.BlockCopy(sourceBuffer, ix, buf.buffer, 0, shadowBufferSize); writer.ReturnBufferAndWrite(buf); } } writer.Flush(); Assert.AreEqual(sourceBuffer, destBuffer); }