public void WriteByteTest()
        {
            string           filePath = "WriteByteTest.arr";
            RandomAccessFile target   = InitRAF(filePath);
            byte             b        = 7;

            target.WriteByte(b);

            target.Seek(0);
            byte actual = target.ReadByte();

            Assert.AreEqual(b, actual);

            target.Close();
        }
        public void ReadByteTest()
        {
            string           filePath = "RAFReadByteTest.arr";
            RandomAccessFile target   = InitRAF(filePath);
            byte             expected = 88;

            target.WriteByte(expected);
            target.Seek(0);

            byte actual = target.ReadByte();

            Assert.AreEqual(expected, actual);

            target.Close();
        }
Esempio n. 3
0
        /// <summary>
        /// Corrupt the byte at the given offset in the given file,
        /// by subtracting 1 from it.
        /// </summary>
        /// <exception cref="System.IO.IOException"/>
        private void CorruptByteInFile(FilePath file, long offset)
        {
            RandomAccessFile raf = new RandomAccessFile(file, "rw");

            try
            {
                raf.Seek(offset);
                int origByte = raf.Read();
                raf.Seek(offset);
                raf.WriteByte(origByte - 1);
            }
            finally
            {
                IOUtils.CloseStream(raf);
            }
        }