public void FillFirstBuffer() { // Write 4 blocks to the stream and then verify they can all be read for (int i = 0; i < 4; i++) { var buffer = Enumerable.Repeat((byte)(i + 1), Piece.BlockSize).ToArray(); level1.Write(file, Piece.BlockSize * i, buffer, 0, buffer.Length); } Assert.AreEqual(Piece.BlockSize * 3, level1.CacheUsed, "#1"); Assert.AreEqual(Piece.BlockSize, level2.CacheUsed, "#2"); // Read them all back out and verify them for (int i = 0; i < 4; i++) { var buffer = new byte[Piece.BlockSize]; level1.Read(file, Piece.BlockSize * i, buffer, 0, Piece.BlockSize); Assert.That(buffer, Is.All.EqualTo((byte)(i + 1))); } Assert.AreEqual(Piece.BlockSize * 3, level1.CacheHits, "#3"); Assert.AreEqual(Piece.BlockSize, level1.CacheMisses, "#4"); Assert.AreEqual(Piece.BlockSize, level2.CacheHits, "#5"); }
public void FillFirstBuffer() { // Write 4 blocks to the stream and then verify they can all be read for (int i = 0; i < 4; i++) { Initialise(buffer, (byte)(i + 1)); level1.Write(singleFile, Piece.BlockSize * i, buffer, 0, buffer.Length); } // Read them all back out and verify them for (int i = 0; i < 4; i++) { level1.Read(singleFile, Piece.BlockSize * i, buffer, 0, Piece.BlockSize); Verify(buffer, (byte)(i + 1)); } }