public void StripedBlockFile_ReadWrite_Forward() { StripedBlockFile bf; byte[] buf = new byte[cbBlock]; byte[] test = new byte[cbBlock]; bf = new StripedBlockFile(GetFiles(), cbBlock, 0, FileMode.Create); try { // Write blocks forward from block 0 on and then // read them back stepping forward as well. for (int i = 0; i < cBlocks; i++) { for (int j = 0; j < cbBlock; j++) { buf[j] = (byte)(j + i); } bf.Write(i, buf, cbBlock); } for (int i = 0; i < cBlocks; i++) { for (int j = 0; j < cbBlock; j++) { test[j] = (byte)(j + i); } bf.Read(i, buf, cbBlock); CollectionAssert.AreEqual(test, buf); } } finally { if (bf != null) { bf.Close(); } DeleteFiles(); } }
public void StripedBlockFile_ReadWrite_Reverse() { StripedBlockFile bf; byte[] buf = new byte[cbBlock]; byte[] test = new byte[cbBlock]; bf = new StripedBlockFile(GetFiles(), cbBlock, 0, FileMode.Create); try { // Write blocks backwards read them back stepping backwards // as well. for (int i = cBlocks - 1; i >= 0; i--) { for (int j = 0; j < cbBlock; j++) { buf[j] = (byte)(j + i + 7); } bf.Write(i, buf, cbBlock); } for (int i = cBlocks - 1; i >= 0; i--) { for (int j = 0; j < cbBlock; j++) { test[j] = (byte)(j + i + 7); } bf.Read(i, buf, cbBlock); CollectionAssert.AreEqual(test, buf); } } finally { if (bf != null) { bf.Close(); } DeleteFiles(); } }