Пример #1
0
        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
        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
        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);
            }
        }