private void ExceptionAtEndTranslationHelper <TExceptionExpected>(Exception exToThrow) { NativeStub myNativeStub = null; Task t = Utility.WrapNativeAsyncInvoke((callback) => { myNativeStub = new NativeStub(callback); return(myNativeStub); }, (adapter) => { throw exToThrow; }, CancellationToken.None, "test"); // complete the task myNativeStub.get_Callback().Invoke(myNativeStub); try { t.Wait(taskWaitTimeout); Assert.Fail("Expected ex"); } catch (AggregateException ex) { Assert.AreEqual(typeof(TExceptionExpected), ex.InnerException.GetType()); } }
public void Initialize() { this.initial = AsyncTaskCallInAdapter.ReleaseComObjectWrapperInstance; Assert.IsInstanceOfType(this.initial, typeof(AsyncTaskCallInAdapter.ReleaseComObjectWrapper), "Release Com Object Wrapper Instance on the call in adapter is not set"); this.releaseComObjectStub = new ReleaseComObjectWrapperStub(); AsyncTaskCallInAdapter.ReleaseComObjectWrapperInstance = this.releaseComObjectStub; this.stub = new NativeStub(); this.asyncEvent = new ManualResetEventSlim(); this.asyncEvent.Reset(); this.baseTask = Task.Factory.StartNew(() => this.asyncEvent.Wait()); }
public void WrapNativeAsyncInvoke_TaskIsCompletedWhenOperationIsDone() { NativeStub myNativeStub = null; Task t = Utility.WrapNativeAsyncInvoke((callback) => { myNativeStub = new NativeStub(callback); return(myNativeStub); }, (adapter) => { }, CancellationToken.None, "test"); // the task is still running Assert.IsFalse(t.IsCompleted); // complete the task myNativeStub.get_Callback().Invoke(myNativeStub); Assert.IsTrue(t.IsCompleted); }