Пример #1
0
 public void Should_find_hook_in_nested_class(Type typeOfHook)
 {
     var c = new HooksCatalog();
     var p = new HooksParser(c);
     p.FindHooks(typeof(When_running_hooks_with_tag_filter.When_matching_tag_for_RunIfHasTags));
     Assert.IsTrue(c.OfType(typeOfHook).Any());
 }
Пример #2
0
 public void Should_find_hook(Type typeOfHook)
 {
     var hooksCatalog = new HooksCatalog();
     var h = new HooksParser(hooksCatalog);
     h.FindHooks(GetType());
     Assert.IsTrue(hooksCatalog.OfType(typeOfHook).Any());
 }
Пример #3
0
        private void OnEvent <T>()
        {
            var tags = GetTags();

            foreach (var hook in hooks.OfType <T>())
            {
                try
                {
                    var hookAttribute = hook.HookAttrib;
                    if (hookAttribute.DontRunIfHasTags.Any() && hookAttribute.DontRunIfHasTags.Intersect(tags).Any())
                    {
                        return;
                    }
                    if (hookAttribute.RunIfHasTags.Any() && hookAttribute.RunIfHasTags.Intersect(tags).Any())
                    {
                        hook.Invoke();
                    }
                    if (hookAttribute.RunIfHasTags.Any() == false)
                    {
                        hook.Invoke();
                    }
                }
                catch (Exception)
                {
                    // hm...
                    throw;
                }
            }
        }
Пример #4
0
            public void Should_find_hook_in_nested_class(Type typeOfHook)
            {
                var c = new HooksCatalog();
                var p = new HooksParser(c);

                p.FindHooks(typeof(When_running_hooks_with_tag_filter.When_matching_tag_for_RunIfHasTags));
                Assert.IsTrue(c.OfType(typeOfHook).Any());
            }
Пример #5
0
            public void Should_find_hook(Type typeOfHook)
            {
                var hooksCatalog = new HooksCatalog();
                var h            = new HooksParser(hooksCatalog);

                h.FindHooks(GetType());
                Assert.IsTrue(hooksCatalog.OfType(typeOfHook).Any());
            }
Пример #6
0
 public void Should_find_hook_on_private_Action_delegate()
 {
     var c = new HooksCatalog();
     var p = new HooksParser(c);
     PrivateDelegateHookCalled = false;
     p.FindHooks(GetType());
     var hooks = c.OfType<BeforeRunAttribute>().ToList();
     hooks.Each(_ => _.Invoke());
     Assert.IsTrue(PrivateDelegateHookCalled);
 }
Пример #7
0
            public void Should_find_hook_on_private_Action_delegate()
            {
                var c = new HooksCatalog();
                var p = new HooksParser(c);

                PrivateDelegateHookCalled = false;
                p.FindHooks(GetType());
                var hooks = c.OfType <BeforeRunAttribute>().ToList();

                hooks.Each(_ => _.Invoke());
                Assert.IsTrue(PrivateDelegateHookCalled);
            }