示例#1
0
        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);
        }
示例#2
0
 public void AsynchronousQueryIsDelegated()
 {
     TestMethodImpl impl = new TestMethodImpl();
     Assert.IsFalse(impl.IsAsynchronousCalled);
     Assert.IsFalse(new WarpedMethodImpl(impl, typeof(Thing), new PropertyDescriptorCollection(null), null).IsAsynchronous);
     Assert.IsTrue(impl.IsAsynchronousCalled);
 }
示例#3
0
        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]));
 }
示例#5
0
        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]));
        }
示例#6
0
        public void AsynchronousQueryIsDelegated()
        {
            TestMethodImpl impl = new TestMethodImpl();

            Assert.IsFalse(impl.IsAsynchronousCalled);
            Assert.IsFalse(new WarpedMethodImpl(impl, typeof(Thing), new PropertyDescriptorCollection(null), null).IsAsynchronous);
            Assert.IsTrue(impl.IsAsynchronousCalled);
        }