public void ProxyForClassWithSuperClass()
        {
            object proxy = _generator.CreateClassProxy(
                typeof(SpecializedServiceClass), new ResultModifiedInvocationHandler( ));

            Assert.IsNotNull(proxy);
            Assert.IsTrue(typeof(ServiceClass).IsAssignableFrom(proxy.GetType()));
            Assert.IsTrue(typeof(SpecializedServiceClass).IsAssignableFrom(proxy.GetType()));

            SpecializedServiceClass inter = (SpecializedServiceClass)proxy;

            Assert.AreEqual(44, inter.Sum(20, 25));
            Assert.AreEqual(-6, inter.Subtract(20, 25));
            Assert.AreEqual(true, inter.Valid);
        }
示例#2
0
        public void MultithreadTest()
        {
            _service = (SpecializedServiceClass)_generator.CreateClassProxy(
                typeof(SpecializedServiceClass),
                new ResultModifiedInvocationHandler( ));

            const int threadCount = 10;

            Thread[] threads = new Thread[threadCount];

            for (int i = 0; i < threadCount; i++)
            {
                threads[i] = new Thread(new ThreadStart(ExecuteMethodUntilSignal));
                threads[i].Start();
            }

            _startEvent.Set();

            Thread.CurrentThread.Join(1 * 2000);

            _stopEvent.Set();
        }