コード例 #1
0
ファイル: ExampleBase.cs プロジェクト: BennieCopeland/NSpec
        public void AssignProperException(Exception contextException)
        {
            if (contextException == null) return; //stick with whatever Exception may or may not be set on this Example

            if (Exception != null && Exception.GetType() != typeof(ExceptionNotThrown))
                Exception = new ExampleFailureException("Context Failure: " + contextException.Message + ", Example Failure: " + Exception.Message, contextException);

            if (Exception == null)
                Exception = new ExampleFailureException("Context Failure: " + contextException.Message, contextException);
        }
コード例 #2
0
ファイル: RunnableExample.cs プロジェクト: darodriguez/NSpec
        public void AssignException(Exception beforeAllException, Exception afterAllException)
        {
            if (example.Pending)
            {
                return;
            }

            // if an exception was thrown before the example (only in `act`) but was expected, ignore it
            Exception unexpectedException = context.ClearExpectedException
                ? null
                : context.ActChain.AnyException();

            Exception previousException =
                beforeAllException ??
                context.BeforeChain.AnyException() ??
                unexpectedException;

            Exception followingException =
                context.AfterChain.AnyException() ??
                afterAllException;

            if (previousException == null && followingException == null)
            {
                // stick with whatever exception may or may not be set on this example
                return;
            }

            if (previousException != null)
            {
                if (example.Exception != null && example.Exception.GetType() != typeof(ExceptionNotThrown))
                {
                    example.Exception = ExampleFailureException
                                        .FromContextAndExample(previousException, example.Exception);

                    return;
                }

                if (example.Exception == null)
                {
                    example.Exception = ExampleFailureException
                                        .FromContext(previousException);

                    return;
                }
            }

            if (example.Exception == null)
            {
                example.Exception = ExampleFailureException.FromContext(followingException);
            }
        }
コード例 #3
0
ファイル: Example.cs プロジェクト: algonzalez/NSpec
        public void AssignProperException(Exception contextException)
        {
            if (contextException == null)
            {
                return;                           //stick with whatever Exception may or may not be set on this Example
            }
            if (Exception != null && Exception.GetType() != typeof(ExceptionNotThrown))
            {
                Exception = new ExampleFailureException("Context Failure: " + contextException.Message + ", Example Failure: " + Exception.Message, contextException);
            }

            if (Exception == null)
            {
                Exception = new ExampleFailureException("Context Failure: " + contextException.Message, contextException);
            }
        }