Ejemplo n.º 1
0
        protected virtual ReportRunResult RunFixture(Fixture fixture)
        {
            if (this.IsAbortPending)
            {
                return(ReportRunResult.Failure);
            }

            FixtureRunnerStarter fixtureStarter = new FixtureRunnerStarter(this, fixture);
            Thread thread = null;

            try
            {
                thread = new Thread(new ThreadStart(fixtureStarter.Start));
                if (fixture.ApartmentState != ApartmentState.Unknown)
                {
                    thread.ApartmentState = fixture.ApartmentState;
                }
                thread.Start();
                // execute and watch for time outs
                if (!thread.Join(fixture.TimeOut))
                {
                    this.Abort();
                    Thread.Sleep(1000);
                    if (thread.ThreadState != ThreadState.Stopped)
                    {
                        thread.Abort();
                    }
                    ReportMonitor monitor = new ReportMonitor();
                    monitor.Start();
                    monitor.Stop();
                    FixtureTimedOutException ex = new FixtureTimedOutException();
                    foreach (RunPipeStarter starter in fixture.Starters)
                    {
                        starter.Fail(monitor, ex);
                        OnRunResult(new ReportRunEventArgs(starter.Result));
                    }
                    thread = null;
                    return(ReportRunResult.Failure);
                }
                thread = null;

                // check if something occured duregin execution
                if (fixtureStarter.ThrowedException != null)
                {
                    throw new FixtureExecutionException(fixture.Name, fixtureStarter.ThrowedException);
                }

                return(fixtureStarter.Result);
            }
            finally
            {
                if (thread != null)
                {
                    thread.Abort();
                    thread = null;
                }
            }
        }
Ejemplo n.º 2
0
        protected virtual ReportRunResult RunFixture(Fixture fixture)
        {
            if (this.IsAbortPending)
                return ReportRunResult.Failure;

            FixtureRunnerStarter fixtureStarter = new FixtureRunnerStarter(this, fixture);
            Thread thread = null;
            try
            {
                thread = new Thread(new ThreadStart(fixtureStarter.Start));
                if (fixture.ApartmentState != ApartmentState.Unknown)
                    thread.ApartmentState = fixture.ApartmentState;
                thread.Start();
                // execute and watch for time outs
                if (!thread.Join(fixture.TimeOut))
                {
                    this.Abort();
                    Thread.Sleep(1000);
                    if (thread.ThreadState != ThreadState.Stopped)
                        thread.Abort();
                    ReportMonitor monitor = new ReportMonitor();
                    monitor.Start();
                    monitor.Stop();
                    FixtureTimedOutException ex = new FixtureTimedOutException();
                    foreach (RunPipeStarter starter in fixture.Starters)
                    {
                        starter.Fail(monitor, ex);
                        OnRunResult(new ReportRunEventArgs(starter.Result));
                    }
                    thread = null;
                    return ReportRunResult.Failure;
                }
                thread = null;

                // check if something occured duregin execution
                if (fixtureStarter.ThrowedException != null)
                    throw new FixtureExecutionException(fixture.Name, fixtureStarter.ThrowedException);

                return fixtureStarter.Result;
            }
            finally
            {
                if (thread != null)
                {
                    thread.Abort();
                    thread = null;
                }
            }
        }