Exemple #1
0
        public void TestBigWrite()
        {
            PipedInputStream  pin  = new PipedInputStream();
            PipedOutputStream pout = new PipedOutputStream(pin);

            Random r = new Random(0);

            byte[] data = new byte [PipedInputStream.PIPE_SIZE * 3];
            r.NextBytes(data);

            ThreadPool.QueueUserWorkItem(delegate {
                pout.Write(data);
                pout.Close();
            });
            int n = 0;

            byte[] buffer = new byte [100];
            int    nr;

            while ((nr = pin.Read(buffer)) != -1)
            {
                for (int i = 0; i < nr; i++)
                {
                    Assert.AreEqual(buffer[i], data[n++], "Position " + n);
                }
            }
        }
Exemple #2
0
 public void Run()
 {
     try {
         while (true)
         {
             int len = mInputStream.Read(mBuffer, 0, 1024);
             mPipedOutputStream.Write(mBuffer, 0, len);
         }
     } catch (IOException e) {
         try {
             mPipedInputStream.Close();
         } catch (IOException ignore) {}
         mIOException = e;
     }
 }
 public virtual void TestTimeout_readByte_Success1()
 {
     @out.Write('a');
     NUnit.Framework.Assert.AreEqual('a', @is.Read());
 }
 /// <exception cref="System.IO.IOException"></exception>
 public FullPipeInputStream(TimeoutOutputStreamTest _enclosing, PipedOutputStream
                            src) : base(src)
 {
     this._enclosing = _enclosing;
     src.Write(new byte[PipedInputStream.PIPE_SIZE]);
 }