예제 #1
0
 public void BeginInvokeWithCallback()
 {
     MockService service = new MockService();
     TypeMethodImpl impl = GetImpl("Sub");
     bool[] called = new bool[1];
     impl.BeginInvoke(service, null, new AsyncCallback(OnInvoked), called);
     Assert.IsTrue(called[0]);
 }
예제 #2
0
 public void BeginInvokeWithoutCallback()
 {
     MockService service = new MockService();
     TypeMethodImpl impl = GetImpl("Sub");
     object state = new object();
     IAsyncResult ar = impl.BeginInvoke(service, null, null, state);
     Assert.IsNotNull(ar);
     Assert.IsTrue(ar.CompletedSynchronously);
     Assert.IsTrue(ar.IsCompleted);
     Assert.AreSame(state, ar.AsyncState);
     Assert.IsNotNull(ar.AsyncWaitHandle);
     Assert.AreSame(impl.Method, service.LastCalledMethod);
 }
예제 #3
0
 public void EndInvokePropagatesThrownException()
 {
     MockService service = new MockService();
     service.NextException = new ApplicationException();
     TypeMethodImpl impl = GetImpl("Erroneous");
     IAsyncResult ar = impl.BeginInvoke(service, null, null, null);
     try
     {
         impl.EndInvoke(service, ar);
         Assert.Fail("Expected " + typeof(TargetMethodException));
     }
     catch (TargetMethodException e)
     {
         Assert.IsNotNull(e.InnerException);
         Assert.AreSame(service.NextException, e.InnerException);
     }
 }
예제 #4
0
        public void CannotCallEndInvokeWithNullService()
        {
            TypeMethodImpl impl = GetImpl("Sub");

            impl.EndInvoke(null, impl.BeginInvoke(new MockService(), null, null, null));
        }