Exemple #1
0
 protected override void Act()
 {
     // reader is configured to read-ahead max. 3 chunks, so chunk4 should not have been read
     Assert.IsFalse(_chunk4BeginRead.WaitOne(0));
     // consume chunk 1
     _actualChunk1 = _reader.Read();
     // consuming chunk1 allows chunk4 to be read-ahead
     Assert.IsTrue(_chunk4BeginRead.WaitOne(200));
     // verify that chunk5 has not yet been read-ahead
     Assert.IsFalse(_chunk5BeginRead.WaitOne(0));
     // consume chunk 2
     _actualChunk2 = _reader.Read();
     // consuming chunk2 allows chunk5 to be read-ahead
     Assert.IsTrue(_chunk5BeginRead.WaitOne(200));
     // pauze until the read-ahead has started waiting a semaphore to become available
     Assert.IsTrue(_waitBeforeChunk6.WaitOne(200));
     // consume remaining parts of chunk 2
     _actualChunk2CatchUp1 = _reader.Read();
     _actualChunk2CatchUp2 = _reader.Read();
     // verify that chunk6 has not yet been read-ahead
     Assert.IsFalse(_chunk6BeginRead.WaitOne(0));
     // consume chunk 3
     _actualChunk3 = _reader.Read();
     // consuming chunk3 allows chunk6 to be read-ahead
     Assert.IsTrue(_chunk6BeginRead.WaitOne(200));
     // consume chunk 4
     _actualChunk4 = _reader.Read();
     // consume chunk 5
     _actualChunk5 = _reader.Read();
     // consume chunk 6
     _actualChunk6 = _reader.Read();
 }
Exemple #2
0
 protected override void Act()
 {
     try
     {
         _reader.Read();
         Assert.Fail();
     }
     catch (SshException ex)
     {
         _actualException = ex;
     }
 }
 protected override void Act()
 {
     // consume chunk 1
     _actualChunk1 = _reader.Read();
     // consume chunk 2
     _actualChunk2 = _reader.Read();
     // wait until chunk3 has been read-ahead
     Assert.IsTrue(_chunk3BeginRead.WaitOne(200));
     // consume remaining parts of chunk 2
     _actualChunk2CatchUp = _reader.Read();
     // consume chunk 3
     _actualChunk3 = _reader.Read();
 }
Exemple #4
0
 protected override void Act()
 {
     // wait for the exception to be signaled by the second call to WaitAny
     _exceptionSignaled.WaitOne(5000);
     // allow a little time to allow SftpFileReader to process exception
     Thread.Sleep(100);
     try
     {
         _reader.Read();
         Assert.Fail();
     }
     catch (SshException ex)
     {
         _actualException = ex;
     }
 }
Exemple #5
0
        protected override void Act()
        {
            _reader.Read();

            // wait until SftpFileReader has starting reading ahead chunk 2
            Assert.IsTrue(_readAheadChunk2.WaitOne(TimeSpan.FromSeconds(5)));
            // signal that we are about to read chunk 2
            _readChunk2.Set();

            try
            {
                _reader.Read();
                Assert.Fail();
            }
            catch (SshException ex)
            {
                _actualException = ex;
            }
        }
 public void ReadAfterDisposeShouldThrowObjectDisposedException()
 {
     try
     {
         _reader.Read();
         Assert.Fail();
     }
     catch (ObjectDisposedException ex)
     {
         Assert.IsNull(ex.InnerException);
         Assert.AreEqual(typeof(SftpFileReader).FullName, ex.ObjectName);
     }
 }
Exemple #7
0
        protected override void Act()
        {
            ThreadAbstraction.ExecuteThread(() =>
            {
                Thread.Sleep(500);
                _reader.Dispose();
                _disposeCompleted.Set();
            });

            try
            {
                _reader.Read();
                Assert.Fail();
            }
            catch (ObjectDisposedException ex)
            {
                _actualException = ex;
            }

            // Dispose may unblock Read() before the dispose has fully completed, so
            // let's wait until it has completed
            _disposeCompleted.WaitOne(500);
        }
 protected override void Act()
 {
     _actualChunk1 = _reader.Read();
     _actualChunk2 = _reader.Read();
     _actualChunk3 = _reader.Read();
 }