Esempio n. 1
0
        void RunBeforeAll(nspec instance)
        {
            // context-level

            if (BeforeAll != null && BeforeAllAsync != null)
            {
                throw new AsyncMismatchException(
                          "A single context cannot set both a 'beforeAll' and an 'beforeAllAsync', please pick one of the two");
            }

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

            BeforeAll.SafeInvoke();

            BeforeAllAsync.SafeInvoke();

            // class (method-level)

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

            BeforeAllInstance.SafeInvoke(instance);

            BeforeAllInstanceAsync.SafeInvoke(instance);
        }
Esempio n. 2
0
        void RunBeforeAll(nspec instance)
        {
            // context-level

            if (BeforeAll != null && BeforeAllAsync != null)
            {
                throw new ArgumentException("A single context cannot have both a 'beforeAll' and an 'beforeAllAsync' set, please pick one of the two");
            }

            BeforeAll.SafeInvoke();

            BeforeAllAsync.SafeInvoke();

            // class (method-level)

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

            BeforeAllInstance.SafeInvoke(instance);

            BeforeAllInstanceAsync.SafeInvoke(instance);
        }
Esempio n. 3
0
        void RunBeforeAll(nspec instance)
        {
            BeforeAll.SafeInvoke();

            BeforeAllInstance.SafeInvoke(instance);
        }