private List<Test> getTests(string assembly)
        {
            var testIsolationProvider = (ITestIsolationProvider)RuntimeAccessor.ServiceLocator.ResolveByComponentId("Gallio.LocalTestIsolationProvider");
            var testIsolationOptions = new TestIsolationOptions();
            ITestIsolationContext testIsolationContext = testIsolationProvider.CreateContext(testIsolationOptions, _logger);

            // Create a test package.
            // You can set a whole bunch of options here.
            var testPackage = new TestPackage();
            testPackage.AddFile(new FileInfo(assembly));
            testPackage.TestFrameworkFallbackMode = TestFrameworkFallbackMode.Strict;

            var testExplorationOptions = new TestExplorationOptions();

            // This query you can answer by exploring tests and looking at their metadata for "TestsOn".
            // You can explore tests using the Explore method of TestDriver. It sends a bunch of
            // messages to an IMessageSink just like Run.  Just scan these messages for tests that
            // match the pattern you like.

            // Alternately, you can build a TestModel once up front and traverse the resulting test tree
            // to find what you need.  The Explore method of testDriver is just like Run, except that
            // it does not run the tests.
            // TestModelSerializer is a little helper we can use to build up a TestModel from test messages on the fly.
            // The TestModel is just a tree of test metadata.  Pretty straightforward.
            TestModel testModel = new TestModel();
            IMessageSink messageSink = TestModelSerializer.CreateMessageSinkToPopulateTestModel(testModel);

            var logProgressMonitorProvider = new LogProgressMonitorProvider(_logger);

            logProgressMonitorProvider.Run((progressMonitor) =>
            {
                _testDriver.Explore(testIsolationContext, testPackage, testExplorationOptions, messageSink, progressMonitor);
            });

            return testModel.AllTests.Where(x => x.IsTestCase).ToList();
        }
        public IEnumerable<AutoTest.TestRunners.Shared.Results.TestResult> Run(RunSettings settings)
        {
            if (!_isInitialized)
                return new AutoTest.TestRunners.Shared.Results.TestResult[] { getNotInitializedResult(settings) };
            var tests = settings.Assembly.Tests.ToList();
            var members = settings.Assembly.Members.ToList();
            var namespaces = settings.Assembly.Namespaces.ToList();

            var runAll = namespaces.Count == 0 && members.Count == 0 && tests.Count == 0;
            var steps = new List<TestStepData>();
            var testResults = new List<AutoTest.TestRunners.Shared.Results.TestResult>();

            // Get a test isolation context.  Here we want to run tests in the same AppDomain.
            var testIsolationProvider = (ITestIsolationProvider)RuntimeAccessor.ServiceLocator.ResolveByComponentId("Gallio.LocalTestIsolationProvider");
            var testIsolationOptions = new TestIsolationOptions();
            ITestIsolationContext testIsolationContext = testIsolationProvider.CreateContext(testIsolationOptions, _logger);

            var testPackage = new TestPackage();
            testPackage.AddFile(new FileInfo(settings.Assembly.Assembly));
            testPackage.TestFrameworkFallbackMode = TestFrameworkFallbackMode.Strict;

            // Create some test exploration options.  Nothing interesting for you here, probably.
            var testExplorationOptions = new TestExplorationOptions();
            var messageSink = new MessageConsumer()
                .Handle<TestStepStartedMessage>((message) =>
                {
                    steps.Add(message.Step);
                })
                .Handle<TestStepFinishedMessage>(message =>
                {
                    var test = steps.FirstOrDefault(x => x.Id.Equals(message.StepId) && x.IsTestCase);
                    if (test == null)
                        return;
                    var fixture = string.Format("{0}.{1}", test.CodeReference.NamespaceName, steps.First(x => x.Id.Equals(test.ParentId)).Name);
                    testResults.Add(new AutoTest.TestRunners.Shared.Results.TestResult(
                        "MbUnit",
                        settings.Assembly.Assembly,
                        fixture,
                        message.Result.Duration.TotalMilliseconds,
                        string.Format("{0}.{1}", fixture, test.Name),
                        convertState(message.Result.Outcome.Status),
                        message.Result.Outcome.DisplayName));
                });

            // Provide a progress monitor.
            var logProgressMonitorProvider = new LogProgressMonitorProvider(_logger);
            var options = new TestExecutionOptions();
            options.FilterSet = new Gallio.Model.Filters.FilterSet<ITestDescriptor>(new OrFilter<ITestDescriptor>(getTestFilter(namespaces, members, tests)));

            // Run the tests.
            logProgressMonitorProvider.Run((progressMonitor) =>
            {
                _testDriver.Run(testIsolationContext, testPackage, testExplorationOptions, options, messageSink, progressMonitor);
            });

            return testResults;
        }