Example #1
0
        /// <exception cref="System.IO.IOException"/>
        public override int Available()
        {
            int avail = @in.Available();

            if (pos + avail > end)
            {
                avail = (int)(end - pos);
            }
            return(avail);
        }
        public virtual void TestSeekReadClosedFile()
        {
            bool supportsSeekOnClosedFiles = IsSupported(SupportsSeekOnClosedFile);

            instream = GetFileSystem().Open(smallSeekFile);
            GetLog().Debug("Stream is of type " + instream.GetType().GetCanonicalName());
            instream.Close();
            try
            {
                instream.Seek(0);
                if (!supportsSeekOnClosedFiles)
                {
                    NUnit.Framework.Assert.Fail("seek succeeded on a closed stream");
                }
            }
            catch (IOException)
            {
            }
            //expected a closed file
            try
            {
                int data = instream.Available();
                NUnit.Framework.Assert.Fail("read() succeeded on a closed stream, got " + data);
            }
            catch (IOException)
            {
            }
            //expected a closed file
            try
            {
                int data = instream.Read();
                NUnit.Framework.Assert.Fail("read() succeeded on a closed stream, got " + data);
            }
            catch (IOException)
            {
            }
            //expected a closed file
            try
            {
                byte[] buffer = new byte[1];
                int    result = instream.Read(buffer, 0, 1);
                NUnit.Framework.Assert.Fail("read(buffer, 0, 1) succeeded on a closed stream, got "
                                            + result);
            }
            catch (IOException)
            {
            }
            //expected a closed file
            //what position does a closed file have?
            try
            {
                long offset = instream.GetPos();
            }
            catch (IOException)
            {
            }
            // its valid to raise error here; but the test is applied to make
            // sure there's no other exception like an NPE.
            //and close again
            instream.Close();
        }
Example #3
0
 /// <exception cref="System.IO.IOException"/>
 public override int Available()
 {
     return(datas.Available() + base.Available());
 }