public static TestResultShim RunTest(TestContext testContext, List <string> traceMessages)
        {
            var startTime  = DateTime.UtcNow;
            var testResult = new TestResultShim();

            Exception existingError = testContext.FixtureContext.GlobalSetupManager.PrepareForTestPosition(testContext.Position);

            if (existingError != null)
            {
                TestResultUtil.Error(testResult, testContext.Name.MultilineName, existingError, null,
                                     TestResultShim.Site.SetUp);
            }
            else
            {
                traceMessages.AddRange(testContext.FixtureContext.GlobalSetupManager.GetTraceMessages());
                try
                {
                    List <string> traceMessages1 = traceMessages;
                    traceMessages1 = traceMessages1 ?? new List <string>();

                    var executionContext = new NJasmineTestRunContext(testContext.Position, testContext.FixtureContext.GlobalSetupManager, traceMessages1);
                    var runner           = new NJasmineTestRunner(executionContext);

                    SpecificationFixture fixture = testContext.FixtureContext.FixtureFactory();

                    fixture.CurrentPosition = TestPosition.At(0);
                    fixture.Visitor         = runner;
                    try
                    {
                        fixture.Run();
                    }
                    finally
                    {
                        executionContext.RunAllPerTestTeardowns();
                    }
                    testResult.Success();
                }
                catch (Exception e)
                {
                    TestResultUtil.Error(testResult, testContext.Name.MultilineName, e, traceMessages);
                }
            }

            testResult.SetExecutionTime(DateTime.UtcNow - startTime);
            return(testResult);
        }
        public static void BuildTestFixture(Type type, INativeTestFactory nativeTestFactory, GlobalSetupOwner globalSetupOwner)
        {
            if (nativeTestFactory is ValidatingNativeTestFactory)
            {
                throw new InvalidOperationException("Do not pass a ValidatingNativeTestFactory here.");
            }

            nativeTestFactory = new ValidatingNativeTestFactory(nativeTestFactory);

            var constructor = type.GetConstructor(new Type[0]);

            Func <SpecificationFixture> fixtureFactory = delegate()
            {
                var fixture = constructor.Invoke(new object[0]) as SpecificationFixture;
                return(fixture);
            };

            var setupManager = globalSetupOwner.GetSetupManager(type, fixtureFactory);

            FixtureContext fixtureContext = new FixtureContext(nativeTestFactory, fixtureFactory, new NameReservations(), setupManager);

            var testContext = new TestContext()
            {
                Position       = TestPosition.At(),
                FixtureContext = fixtureContext,
                Name           = new TestName
                {
                    FullName      = type.Namespace + "." + type.Name,
                    Shortname     = type.Name,
                    MultilineName = type.Namespace + "." + type.Name
                }
            };

            var explicitReason = ExplicitAttributeReader.GetFor(type);

            var result = BuildSuiteForTextContext(fixtureContext, testContext, fixtureContext.GetSpecificationRootAction(), true, explicitReason);

            nativeTestFactory.SetRoot(result);
        }