private IEnumerable<IExecutionStep> toExecutionSteps(FixtureLibrary library, Fixture fixture) { var setup = SilentAction.AsCritical("Fixture", Stage.setup, x => { fixture.Context = x; fixture.SetUp(); }, this); setup.Subject = Key + ":SetUp"; yield return setup; // Ignore comments! foreach (var step in Children.OfType<Step>()) { var grammar = fixture.GrammarFor(step.Key); yield return grammar.CreatePlan(step, library); } var teardown = SilentAction.AsCritical("Fixture", Stage.teardown, x => fixture.TearDown(), this); teardown.Subject = Key + ":TearDown"; yield return teardown; }
protected virtual void RunFixtureTearDown(Fixture fixture, object fixtureInstance) { if (fixture == null) { throw new ArgumentNullException("fixture"); } ReportMonitor monitor = new ReportMonitor(); try { monitor.Start(); fixture.TearDown(fixtureInstance); monitor.Stop(); if (fixture.HasTearDown) { ReportSetUpAndTearDown tearDown = new ReportSetUpAndTearDown("TestFixtureTearDown", monitor); if (this.Report != null) { this.Report.TestFixtureTearDown(fixture, tearDown); } this.OnTestFixtureTearDown(new ReportSetUpAndTearDownEventArgs(tearDown)); } } catch (Exception ex) { monitor.Stop(); ReportSetUpAndTearDown tearDown = new ReportSetUpAndTearDown( "TestFixtureTearDown", monitor, ex); if (this.Report != null) { this.Report.TestFixtureTearDown(fixture, tearDown); } this.OnTestFixtureTearDown(new ReportSetUpAndTearDownEventArgs(tearDown)); } }
protected virtual void RunFixtureTearDown(Fixture fixture, object fixtureInstance) { if (fixture == null) throw new ArgumentNullException("fixture"); ReportMonitor monitor = new ReportMonitor(); try { monitor.Start(); fixture.TearDown(fixtureInstance); monitor.Stop(); if (fixture.HasTearDown) { ReportSetUpAndTearDown tearDown = new ReportSetUpAndTearDown("TestFixtureTearDown", monitor); if (this.Report != null) this.Report.TestFixtureTearDown(fixture, tearDown); this.OnTestFixtureTearDown(new ReportSetUpAndTearDownEventArgs(tearDown)); } } catch (Exception ex) { monitor.Stop(); ReportSetUpAndTearDown tearDown = new ReportSetUpAndTearDown( "TestFixtureTearDown", monitor, ex); if (this.Report != null) this.Report.TestFixtureTearDown(fixture, tearDown); this.OnTestFixtureTearDown(new ReportSetUpAndTearDownEventArgs(tearDown)); } }