예제 #1
0
        public void Fail(ReportMonitor monitor, Exception ex)
        {
            if (monitor == null)
            {
                throw new ArgumentNullException("monitor");
            }
            if (ex == null)
            {
                throw new ArgumentNullException("ex");
            }

            this.Start();
            this.result = ReportRun.Failure(this.Pipe, monitor, ex);
            this.Failure();
        }
예제 #2
0
        public void Run(Object fixture, bool IsExplicit)
        {
            if (fixture == null)
            {
                throw new ArgumentNullException("fixture");
            }

            // create arguments...
            ArrayList args = new ArrayList();

            this.abortPending = false;
            this.monitor.Start();
            this.Start();

            Exception testException = null;

            foreach (RunInvokerVertex v in pipe.Invokers)
            {
                if (!v.HasInvoker)
                {
                    continue;
                }

                if (v.Invoker is ExplicitRunInvoker && !IsExplicit)
                {
                    testException = new IgnoreRunException("Explicit selection required.");
                }

                // if exception has already been thrown, execute non test only
                if (testException != null)
                {
                    if (!v.Invoker.Generator.IsTest)
                    {
                        // execute tear down code and drop exceptions
                        try
                        {
                            v.Invoker.Execute(fixture, args);
                        }
                        catch (Exception)
                        { }
                    }
                }
                else
                {
                    try
                    {
                        if (this.IsAbortPending)
                        {
                            continue;
                        }

                        if (v.Invoker.Generator.IsTest)
                        {
                            v.Invoker.Execute(fixture, args);
                        }
                        else
                        {
                            // can't re-use args for TearDown, or we get a parameter mismatch!
                            v.Invoker.Execute(fixture, new ArrayList());
                        }
                    }
                    catch (Exception ex)
                    {
                        testException = ex;
                    }
                }
            }

            this.monitor.Stop();

            // success
            if (testException == null)
            {
                this.result = ReportRun.Success(this.pipe, this.monitor);
                this.Success();
            }
            else
            {
                // get rid of TargetInvocationException
                if (testException.GetType() == typeof(TargetInvocationException))
                {
                    testException = testException.InnerException;
                }

                // check if ignoreexception
                if (testException is IgnoreRunException)
                {
                    this.result = ReportRun.Ignore(this.pipe, this.monitor);
                    this.Ignore();
                }
                // failure
                else
                {
                    this.result = ReportRun.Failure(this.pipe, this.monitor, testException);
                    this.Failure();
                }
            }
        }