private void Cleanup()
        {
            if (this.dbRunner == null)
                return;

            this.dbRunner.Dispose();
            this.dbRunner = null;
        }
        public Task<List<TestResult>> RunAllTests(IProgress<ProgressReport> progress, CancellationToken token, string ravenVersionFolderPath)
        {
            var task = Task.Factory.StartNew<List<TestResult>>(() =>
                {
                    this.Cleanup();

                    var testGroups = GetAllRavenDotNetApiTests();
                    var testResults = new List<TestResult>();

                    var dbPort = 8080;

                    var clientDllPath = Path.Combine(ravenVersionFolderPath, Constants.Paths.ClientDllPartialPath);
                    var serverStandaloneExePath = Path.Combine(ravenVersionFolderPath, Constants.Paths.ServerStandaloneExePartialPath);

                    using (dbRunner = DbRunner.Run(dbPort, serverStandaloneExePath))
                    {
                        Console.WriteLine("Server startup time: {0}s", dbRunner.StartupTime.TotalSeconds);

                        using (var domainContainer = new ClientWrapper.v2_5_2750.DomainContainer(
                            clientDllPath, "version1", dbPort))
                        {
                            var wrapper = domainContainer.Wrapper;
                            System.Console.WriteLine("Using .Net wrapper version: " + wrapper.GetVersion());

                            foreach (var testGroup in testGroups)
                            {
                                InterruptExecutionIfCancellationRequested(token);
                                var obj = Activator.CreateInstance(testGroup.GroupType, new object[] { wrapper });
                                foreach (var test in testGroup.Tests)
                                {
                                    InterruptExecutionIfCancellationRequested(token);
                                    RunExecutableAttributesCodeBeforeTest(test, wrapper);
                                    var result = RunTest(testGroup, test, obj);
                                    testResults.Add(result);
                                    ReportResultAsProgressReport(progress, result);
                                }
                            }
                        }
                    }

                    return testResults;
                }, token);
            return task;
        }