Ejemplo n.º 1
0
        [Test] public void GetInvokerOrNull_FiltersMethod()
        {
            Base b = new Base();

            var dProtected = Reflections.GetInvokerOrNull <Func <T> >(
                b, b.GetType(), "ProtectedVirtualInstance",
                BindingFlags.Instance | BindingFlags.NonPublic, null);

            Assert.NotNull(dProtected);

            var dPrivate = Reflections.GetInvokerOrNull <Action <T> >(
                b, b.GetType(), "PrivateInstance",
                BindingFlags.Instance | BindingFlags.NonPublic, null);

            Assert.NotNull(dPrivate);

            dProtected = Reflections.GetInvokerOrNull <Func <T> >(
                b, b.GetType(), "ProtectedVirtualInstance",
                BindingFlags.Instance | BindingFlags.NonPublic, m => m.IsFamily);
            Assert.NotNull(dProtected);

            dPrivate = Reflections.GetInvokerOrNull <Action <T> >(
                b, b.GetType(), "PrivateInstance",
                BindingFlags.Instance | BindingFlags.NonPublic, m => m.IsFamily);
            Assert.Null(dPrivate);
        }