public void AsyncInvocation() { TestMethodImpl baseMethod = new TestMethodImpl(); WarpedMethodImpl warpedMethod = new WarpedMethodImpl(baseMethod, typeof(Thing), TypeDescriptor.GetProperties(typeof(Thing)), TypeDescriptor.GetProperties(typeof(ResultThing))[0]); DummyService service = new DummyService(); object[] args = new object[] { 42, "foobar" }; baseMethod.InvokeResult = new ResultThing(123); IAsyncResult ar = warpedMethod.BeginInvoke(service, args, null, null); object result = warpedMethod.EndInvoke(service, ar); Assert.AreSame(ar, baseMethod.EndInvokeAsyncResult); Assert.AreSame(service, baseMethod.InvokeService); Assert.IsNotNull(baseMethod.InvokeArgs); Assert.AreEqual(1, baseMethod.InvokeArgs.Length); Assert.IsNotNull(baseMethod.InvokeArgs[0]); Thing thing = baseMethod.InvokeArgs[0] as Thing; Assert.IsInstanceOfType(typeof(Thing), thing); Assert.AreEqual(args[0], thing.Int); Assert.AreEqual(args[1], thing.Str); Assert.AreEqual(baseMethod.InvokeResult.Result, result); }
public void InvocationWithNoResult() { TestMethodImpl baseMethod = new TestMethodImpl(); WarpedMethodImpl warpedMethod = new WarpedMethodImpl(baseMethod, typeof(Thing), TypeDescriptor.GetProperties(typeof(Thing)), null); Assert.IsNull(warpedMethod.Invoke(new DummyService(), new object[0])); }