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); } }
public void GatedInvoker_Invoke_MultipleThreads() { var thread1 = new Thread(new ThreadStart(Thread1)); var thread2 = new Thread(new ThreadStart(Thread2)); invoker = new GatedInvoker(this); count = 0; failed = false; thread1.Start(); thread2.Start(); thread1.Join(); thread2.Join(); Assert.IsFalse(failed); Assert.AreEqual(10000, count); }
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]); }