public void Read_RemainingIndexInputLargerThanReadCount_ReturnsReadCount() { byte[] buffer = new byte[8.KiloBytes()]; new Random().NextBytes(buffer); IndexInputStream stream = new IndexInputStream(new MockIndexInput(buffer)); int readBytes = 2.KiloBytes(); byte[] readBuffer = new byte[readBytes]; Assert.AreEqual(stream.Read(readBuffer, 0, readBytes), readBytes); }
public void Read_RemainingIndexInputLargerThanReadCount_ReturnsExpectedSection([Range(1, 8)] int section) { byte[] buffer = new byte[8.KiloBytes()]; new Random().NextBytes(buffer); IndexInputStream stream = new IndexInputStream(new MockIndexInput(buffer)); int readBytes = 1.KiloBytes(); byte[] readBuffer = new byte[readBytes]; for (int i = section; i > 0; i--) { stream.Read(readBuffer, 0, readBytes); } Assert.AreEqual(readBuffer, buffer.Skip((section - 1) * readBytes).Take(readBytes).ToArray()); }