예제 #1
0
파일: Context.cs 프로젝트: devsaurabh/NSpec
        public void RunAfters(nspec instance)
        {
            // context-level

            if (After != null && AfterAsync != null)
            {
                throw new ArgumentException("A single context cannot have both an 'after' and an 'afterAsync' set, please pick one of the two");
            }

            After.SafeInvoke();

            AfterAsync.SafeInvoke();

            // class (method-level)

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

            AfterInstance.SafeInvoke(instance);

            AfterInstanceAsync.SafeInvoke(instance);

            // parent chain

            RecurseAncestors(c => c.RunAfters(instance));
        }
예제 #2
0
        public void RunAfters(nspec instance)
        {
            After.SafeInvoke();

            AfterInstance.SafeInvoke(instance);

            RecurseAncestors(c => c.RunAfters(instance));
        }
예제 #3
0
파일: Context.cs 프로젝트: qipa/NSpec
        public void RunAfters(nspec instance)
        {
            // context-level

            if (After != null && AfterAsync != null)
            {
                throw new AsyncMismatchException(
                          "A single context cannot set both an 'after' and an 'afterAsync', please pick one of the two");
            }

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

            After.SafeInvoke();

            AfterAsync.SafeInvoke();

            // class (method-level)

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

            AfterInstance.SafeInvoke(instance);

            AfterInstanceAsync.SafeInvoke(instance);

            // parent chain

            RecurseAncestors(c => c.RunAfters(instance));
        }