Ejemplo n.º 1
0
        public void TestReadFileDataToBuffer_Big()
        {
            var hint = log.CreateFile();

            logReader.Close();
            log.Close();
            var stream      = new FileStream(filename, FileMode.Open, FileAccess.ReadWrite, FileShare.ReadWrite);
            var newFileSize = FileLogTestsHelper.CreateBigLogFile(hint.Hint, stream);

            stream.Close();
            log = new FileLog(filename, FileMode.Open);
            log.AppendDataToFile(hint, new ByteArray(new byte[] { 1, 2, 3, 4 }));
            byte[] buffer = new byte[128];
            buffer[0] = 15;
            logReader = log.CreateReader();
            logReader.ReadFileDataToBuffer(hint, buffer, newFileSize, 4, 1);
            Assert.Equal(15, buffer[0]);
            Assert.Equal(1, buffer[1]);
            Assert.Equal(2, buffer[2]);
        }
Ejemplo n.º 2
0
        public void TestReadFileDataToBuffer_Normal()
        {
            var hint = log.CreateFile();

            byte[] buffer = new byte[128];
            buffer[0] = 15;
            Assert.Throws(typeof(IndexOutOfRangeException), () => logReader.ReadFileDataToBuffer(hint, buffer, 0, 1, 0));
            Assert.Throws(typeof(IndexOutOfRangeException), () => logReader.ReadFileDataToBuffer(hint, buffer, 1, 0, 0));
            Assert.Throws(typeof(IndexOutOfRangeException), () => logReader.ReadFileDataToBuffer(hint, buffer, 1, 1, 0));
            logReader.ReadFileDataToBuffer(hint, buffer, 0, 0, 0);
            Assert.Equal(15, buffer[0]);
            log.AppendDataToFile(hint, new ByteArray(new byte[] { 1, 2, 3, 4 }));
            Assert.Throws(typeof(IndexOutOfRangeException), () => logReader.ReadFileDataToBuffer(hint, buffer, 4, 1, 0));
            Assert.Equal(15, buffer[0]);
            logReader.ReadFileDataToBuffer(hint, buffer, 1, 2, 1);
            Assert.Equal(15, buffer[0]);
            Assert.Equal(2, buffer[1]);
            Assert.Equal(3, buffer[2]);
        }