コード例 #1
0
ファイル: Context.cs プロジェクト: darodriguez/NSpec
        /// <summary>
        /// Test execution happens in three phases: this is the second phase.
        /// </summary>
        /// <remarks>
        /// Here all contexts and all their examples are traversed again to set proper exception
        /// on examples, giving priority to exceptions from: inherithed beforeAll, beforeAll,
        /// context (befores/ acts/ it/ afters), afterAll, inherithed afterAll.
        /// </remarks>
        public virtual void AssignExceptions(bool recurse = true)
        {
            var beforeAllException = BeforeAllChain.AnyException();
            var afterAllException  = AfterAllChain.AnyException();

            for (int i = 0; i < runnables.Count; i++)
            {
                runnables[i].AssignException(beforeAllException, afterAllException);
            }

            if (recurse)
            {
                Contexts.Do(c => c.AssignExceptions(recurse));
            }
        }
コード例 #2
0
ファイル: Context.cs プロジェクト: darodriguez/NSpec
        public override string ToString()
        {
            string levelText   = $"L{Level}";
            string exampleText = $"{Examples.Count} exm";
            string contextText = $"{Contexts.Count} ctx";

            var exception =
                BeforeAllChain.AnyException() ??
                BeforeChain.AnyException() ??
                ActChain.AnyException() ??
                AfterChain.AnyException() ??
                AfterAllChain.AnyException();

            string exceptionText = exception?.GetType().Name ?? String.Empty;

            return(String.Join(",", new []
            {
                Name, levelText, exampleText, contextText, exceptionText,
            }));
        }