Lucene.Net.Index.TestCompoundFile.Demo_FSIndexInputBug C# (CSharp) Метод

Demo_FSIndexInputBug() приватный Метод

private Demo_FSIndexInputBug ( Directory fsdir, string file ) : void
fsdir Directory
file string
Результат void
        private void Demo_FSIndexInputBug(Directory fsdir, string file)
        {
            // Setup the test file - we need more than 1024 bytes
            IndexOutput os = fsdir.CreateOutput(file, IOContext.DEFAULT);
            for (int i = 0; i < 2000; i++)
            {
                os.WriteByte((byte)(sbyte)i);
            }
            os.Dispose();

            IndexInput @in = fsdir.OpenInput(file, IOContext.DEFAULT);

            // this read primes the buffer in IndexInput
            @in.ReadByte();

            // Close the file
            @in.Dispose();

            // ERROR: this call should fail, but succeeds because the buffer
            // is still filled
            @in.ReadByte();

            // ERROR: this call should fail, but succeeds for some reason as well
            @in.Seek(1099);

            try
            {
                // OK: this call correctly fails. We are now past the 1024 internal
                // buffer, so an actual IO is attempted, which fails
                @in.ReadByte();
                Assert.Fail("expected readByte() to throw exception");
            }
            catch (IOException e)
            {
                // expected exception
            }
        }