Esempio n. 1
0
        public void IsSignatureCompatible()
        {
            DelegateInfo del    = new DelegateInfo(typeof(FooHandler));
            MethodInfo   method = GetType().GetMethod("DoFoo");

            Assert.IsFalse(del.IsSignatureCompatible(method));
        }
Esempio n. 2
0
        public void IsSignatureCompatibleWithBadMethods()
        {
            DelegateInfo del = new DelegateInfo(typeof(FooHandler));

            // null method...
            MethodInfo method = GetType().GetMethod("SeaBass said that? Well, if that guy over there is SeaBass...");

            Assert.IsFalse(del.IsSignatureCompatible(method));

            // method that doesn;t have the required number of parameters...
            method = GetType().GetMethod("OddNumberOfParametersForFooHandler");
            Assert.IsFalse(del.IsSignatureCompatible(method));

            // method that doesn't have the required number of parameters...
            method = GetType().GetMethod("IncompatibleParametersForFooHandler");
            Assert.IsFalse(del.IsSignatureCompatible(method));
        }
Esempio n. 3
0
        public void IsSignatureCompatibleWithInnerClassStaticMethod()
        {
            DelegateInfo del    = new DelegateInfo(typeof(FooHandler));
            MethodInfo   method =
                typeof(Yossarian).GetMethod(
                    "DoFoo",
                    BindingFlags.Public | BindingFlags.Static);

            Assert.IsTrue(del.IsSignatureCompatible(method));
        }
Esempio n. 4
0
        public void IsSignatureCompatibleStaticVersion()
        {
            EventInfo evt = typeof(Assembly).GetEvent("ModuleResolve");

            MethodInfo rubbishMethod = GetType().GetMethod("MethodSignatureIsCompatibleStatic");

            Assert.IsFalse(DelegateInfo.IsSignatureCompatible(evt, rubbishMethod));

            MethodInfo compatibleMethod = typeof(Yossarian).GetMethod("Resolve");

            Assert.IsTrue(DelegateInfo.IsSignatureCompatible(evt, compatibleMethod));

            Assert.IsFalse(DelegateInfo.IsSignatureCompatible(null, compatibleMethod));
            Assert.IsFalse(DelegateInfo.IsSignatureCompatible(evt, null));
        }