Esempio n. 1
0
        public void RunActs(nspec instance)
        {
            // parent chain

            RecurseAncestors(c => c.RunActs(instance));

            // class (method-level)

            if (ActInstance != null && ActInstanceAsync != null)
            {
                throw new ArgumentException("A single class cannot have both a sync and an async class-level 'act_each' set, please pick one of the two");
            }

            ActInstance.SafeInvoke(instance);

            ActInstanceAsync.SafeInvoke(instance);

            // context-level

            if (Act != null && ActAsync != null)
            {
                throw new ArgumentException("A single context cannot have both an 'act' and an 'actAsync' set, please pick one of the two");
            }

            Act.SafeInvoke();

            ActAsync.SafeInvoke();
        }
Esempio n. 2
0
        public void RunActs(nspec instance)
        {
            RecurseAncestors(c => c.RunActs(instance));

            ActInstance.SafeInvoke(instance);

            Act.SafeInvoke();
        }
Esempio n. 3
0
        public void RunActs(nspec instance)
        {
            // parent chain

            RecurseAncestors(c => c.RunActs(instance));

            // class (method-level)

            if (ActInstance != null && ActInstanceAsync != null)
            {
                throw new AsyncMismatchException(
                          "A spec class with all its ancestors cannot set both sync and async class-level 'act_each' hooks, they should either be all sync or all async");
            }

            ActInstance.SafeInvoke(instance);

            ActInstanceAsync.SafeInvoke(instance);

            // context-level

            if (Act != null && ActAsync != null)
            {
                throw new AsyncMismatchException(
                          "A single context cannot set both an 'act' and an 'actAsync', please pick one of the two");
            }

            if (Act != null && Act.IsAsync())
            {
                throw new AsyncMismatchException(
                          "'act' cannot be set to an async delegate, please use 'actAsync' instead");
            }

            Act.SafeInvoke();

            ActAsync.SafeInvoke();
        }