Beispiel #1
0
        public void IsDisabledByProvider_InvalidProvider_Throws(Type providerType)
        {
            MethodInfo method            = typeof(Functions1).GetMethod("DisabledAtMethodLevel_CustomType_Static", BindingFlags.Public | BindingFlags.Static);
            InvalidOperationException ex = Assert.Throws <InvalidOperationException>(() =>
            {
                HostListenerFactory.IsDisabledByProvider(providerType, method, DefaultJobActivator.Instance);
            });

            Assert.Equal(string.Format("Type '{0}' must declare a method 'IsDisabled' returning bool and taking a single parameter of Type MethodInfo.", providerType.Name), ex.Message);
        }
Beispiel #2
0
        public void IsDisabledByProvider_ValidProvider_InvokesProvider()
        {
            Assert.Null(DisableProvider_Static.Method);
            MethodInfo method = typeof(Functions1).GetMethod("DisabledAtMethodLevel_CustomType_Static", BindingFlags.Public | BindingFlags.Static);

            HostListenerFactory.IsDisabledByProvider(typeof(DisableProvider_Static), method, DefaultJobActivator.Instance);
            Assert.Same(method, DisableProvider_Static.Method);

            Assert.Null(DisableProvider_Instance.Method);
            method = typeof(Functions1).GetMethod("DisabledAtMethodLevel_CustomType_Static", BindingFlags.Public | BindingFlags.Static);
            HostListenerFactory.IsDisabledByProvider(typeof(DisableProvider_Instance), method, DefaultJobActivator.Instance);
            Assert.Same(method, DisableProvider_Static.Method);
        }