예제 #1
0
        public void EndInvoke_CompletedWithException()
        {
            object    state     = "STATE";
            Exception exception = new IOException();
            var       target    = new SftpDownloadAsyncResult(null, state);

            target.SetAsCompleted(exception, true);

            try
            {
                target.EndInvoke();
                Assert.Fail();
            }
            catch (IOException ex)
            {
                Assert.AreSame(exception, ex);
            }
        }
예제 #2
0
        public void SetAsCompleted_Exception_CompletedSynchronously()
        {
            var          downloadCompleted = new ManualResetEvent(false);
            object       state             = "STATE";
            Exception    exception         = new IOException();
            IAsyncResult callbackResult    = null;
            var          target            = new SftpDownloadAsyncResult(asyncResult =>
            {
                downloadCompleted.Set();
                callbackResult = asyncResult;
            }, state);

            target.SetAsCompleted(exception, true);

            Assert.AreSame(target, callbackResult);
            Assert.IsFalse(target.IsDownloadCanceled);
            Assert.IsTrue(target.IsCompleted);
            Assert.IsTrue(target.CompletedSynchronously);
            Assert.IsTrue(downloadCompleted.WaitOne(TimeSpan.Zero));
        }