public static void TestLongerReadWrite() { byte[] bytesToWrite = new FakeRandomGenerator().Generate(V2AxCryptDataStream.WriteChunkSize + V2AxCryptDataStream.WriteChunkSize / 2); byte[] buffer = new byte[bytesToWrite.Length + 2000]; using (V2AxCryptDataStream axCryptDataStreamWriter = V2AxCryptDataStream.Create(new MemoryStream(buffer))) { AxCrypt1Guid.Write(axCryptDataStreamWriter.Chained); new PreambleHeaderBlock().Write(axCryptDataStreamWriter.Chained); new DataHeaderBlock().Write(axCryptDataStreamWriter.Chained); axCryptDataStreamWriter.Write(bytesToWrite, 0, bytesToWrite.Length); axCryptDataStreamWriter.Flush(); new V2HmacHeaderBlock().Write(axCryptDataStreamWriter.Chained); } using (AxCryptReader reader = new TestingAxCryptReader(new LookAheadStream(new MemoryStream(buffer)))) { while (reader.Read()) { ; } reader.SetStartOfData(); using (V2AxCryptDataStream axCryptDataStreamReader = V2AxCryptDataStream.Create(reader, Stream.Null)) { byte[] bytesRead = new byte[bytesToWrite.Length]; int offset = 0; int count; do { count = axCryptDataStreamReader.Read(bytesRead, offset, 100); offset += count; } while (count > 0); Assert.That(bytesRead, Is.EquivalentTo(bytesToWrite)); } } }