public TestBuilder RunSuiteAction(FixtureDiscoveryContext buildContext, GlobalSetupManager globalSetup, Action action, bool isOuterScopeOfSpecification, TestBuilder resultBuilder) { var builder = new NJasmineTestSuiteBuilder(_nativeTestFactory, resultBuilder, buildContext, globalSetup); var exception = buildContext.RunActionWithVisitor(_position.GetFirstChildPosition(), action, builder); if (exception == null) { builder.VisitAccumulatedTests(v => resultBuilder.AddChildTest(v)); } else { var failingSuiteAsTest = new TestBuilder(_nativeTestFactory.ForFailingSuite(_position, exception)); failingSuiteAsTest.FullName = resultBuilder.FullName; failingSuiteAsTest.Shortname = resultBuilder.Shortname; failingSuiteAsTest.MultilineName = resultBuilder.MultilineName; buildContext.NameGenator.ReserveName(failingSuiteAsTest); if (isOuterScopeOfSpecification) { resultBuilder.AddChildTest(failingSuiteAsTest); } else { return failingSuiteAsTest; } } return resultBuilder; }
public Test BuildNJasmineTestSuite(FixtureDiscoveryContext buildContext, GlobalSetupManager globalSetup, Action action, bool isOuterScopeOfSpecification) { var builder = new NJasmineTestSuiteBuilder(this, buildContext, globalSetup); var exception = buildContext.RunActionWithVisitor(Position.GetFirstChildPosition(), action, builder); if (exception == null) { builder.VisitAccumulatedTests(Add); } else { var nJasmineInvalidTestSuite = new NJasmineInvalidTestSuite(exception, Position); nJasmineInvalidTestSuite.TestName.FullName = TestName.FullName; nJasmineInvalidTestSuite.TestName.Name = TestName.Name; nJasmineInvalidTestSuite.SetMultilineName(this.GetMultilineName()); if (isOuterScopeOfSpecification) { Add(nJasmineInvalidTestSuite); } else { return nJasmineInvalidTestSuite; } } return this; }
public Test BuildNJasmineTestSuite(AllSuitesBuildContext buildContext, GlobalSetupManager globalSetup, Action action, bool isOuterScopeOfSpecification) { var builder = new NJasmineTestSuiteBuilder(this, buildContext, globalSetup); Exception exception = null; var originalVisitor = buildContext._fixtureInstanceForDiscovery.Visitor; buildContext._fixtureInstanceForDiscovery.CurrentPosition = Position; buildContext._fixtureInstanceForDiscovery.CurrentPosition = buildContext._fixtureInstanceForDiscovery.CurrentPosition.GetFirstChildPosition(); buildContext._fixtureInstanceForDiscovery.Visitor = builder; try { try { action(); } catch (Exception e) { exception = e; } if (exception == null) { builder.VisitAccumulatedTests(Add); } else { var nJasmineInvalidTestSuite = new NJasmineInvalidTestSuite(exception, Position); nJasmineInvalidTestSuite.TestName.FullName = TestName.FullName; nJasmineInvalidTestSuite.TestName.Name = TestName.Name; nJasmineInvalidTestSuite.SetMultilineName(this.GetMultilineName()); if (isOuterScopeOfSpecification) { Add(nJasmineInvalidTestSuite); } else { return nJasmineInvalidTestSuite; } } } finally { buildContext._fixtureInstanceForDiscovery.Visitor = originalVisitor; } return this; }