Beispiel #1
0
 private void Thread1()
 {
     for (int i = 0; i < 5000; i++)
     {
         invoker.Invoke("Method3");
     }
 }
Beispiel #2
0
        public void GatedInvoker_Invoke_ReturnsString()
        {
            var    invoker = new GatedInvoker(this);
            object result;

            result = invoker.Invoke("Method2", 10, 20, "hello world!");
            Assert.AreEqual("foobar", result);
            Assert.AreEqual(10, args[0]);
            Assert.AreEqual(20, args[1]);
            Assert.AreEqual("hello world!", args[2]);

            // Do it again to make sure that MethodInfo caching
            // doesn't mess things up.

            result = invoker.Invoke("Method2", 10, 20, "hello world!");
            Assert.AreEqual("foobar", result);
            Assert.AreEqual(10, args[0]);
            Assert.AreEqual(20, args[1]);
            Assert.AreEqual("hello world!", args[2]);
        }
Beispiel #3
0
        public void GatedInvoker_MethodNotFound()
        {
            var invoker = new GatedInvoker(this);

            try
            {
                invoker.Invoke("not found");
                Assert.Fail("Expected an ArgumentException(\"Method not found\")");
            }
            catch (Exception e)
            {
                Assert.AreEqual(typeof(ArgumentNullException).Name, e.GetType().Name);
            }
        }