public static MongoDbServerDescriptor CreateMongoDbServerInstance()
        {
            var processExecutorFactory          = new ProcessExecutorFactory();
            var mongoDbServerProcessFactory     = new MongoDbServerProcessFactory();
            var mongoDbConnectionMonitorFactory = new MongoDbConnectionMonitorFactory();

            var processExecutor      = processExecutorFactory.CreateProcessExecutor();
            var mongoDbServerProcess = mongoDbServerProcessFactory.CreateMongoDbServerProcess();

            processExecutor.StartProcess(mongoDbServerProcess);

            var mongoDbConnectionMonitor = mongoDbConnectionMonitorFactory.CreateMongoDbConnectionMonitor();

            mongoDbConnectionMonitor.WaitForMongoDbServer(mongoDbServerProcess.ServerHost, mongoDbServerProcess.ServerPort);

            return(new MongoDbServerDescriptor()
            {
                Host = mongoDbServerProcess.ServerHost,
                Port = mongoDbServerProcess.ServerPort
            });
        }
Beispiel #2
0
        public static IExecutionStrategy CreateExecutionStrategy(ExecutionStrategyType type, int portNumber)
        {
            IExecutionStrategy executionStrategy;
            var tasksService                  = new TasksService();
            var processExecutorFactory        = new ProcessExecutorFactory(tasksService);
            var submissionProcessorIdentifier = portNumber.ToString();

            switch (type)
            {
            case ExecutionStrategyType.CompileExecuteAndCheck:
                executionStrategy = new CompileExecuteAndCheckExecutionStrategy(
                    GetCompilerPath,
                    processExecutorFactory,
                    Settings.MsBuildBaseTimeUsedInMilliseconds,
                    Settings.MsBuildBaseMemoryUsedInBytes);
                break;

            case ExecutionStrategyType.CPlusPlusCompileExecuteAndCheckExecutionStrategy:
                executionStrategy = new CPlusPlusCompileExecuteAndCheckExecutionStrategy(
                    GetCompilerPath,
                    processExecutorFactory,
                    Settings.GPlusPlusBaseTimeUsedInMilliseconds,
                    Settings.GPlusPlusBaseMemoryUsedInBytes);
                break;

            case ExecutionStrategyType.CPlusPlusZipFileExecutionStrategy:
                executionStrategy = new CPlusPlusZipFileExecutionStrategy(
                    GetCompilerPath,
                    processExecutorFactory,
                    Settings.GPlusPlusBaseTimeUsedInMilliseconds,
                    Settings.GPlusPlusBaseMemoryUsedInBytes);
                break;

            case ExecutionStrategyType.DotNetCoreCompileExecuteAndCheck:
                executionStrategy = new DotNetCoreCompileExecuteAndCheckExecutionStrategy(
                    GetCompilerPath,
                    processExecutorFactory,
                    Settings.DotNetCoreRuntimeVersion,
                    Settings.DotNetCscBaseTimeUsedInMilliseconds,
                    Settings.DotNetCscBaseMemoryUsedInBytes);
                break;

            case ExecutionStrategyType.DotNetCoreTestRunner:
                executionStrategy = new DotNetCoreTestRunnerExecutionStrategy(
                    GetCompilerPath,
                    processExecutorFactory,
                    Settings.DotNetCliBaseTimeUsedInMilliseconds,
                    Settings.DotNetCliBaseMemoryUsedInBytes);
                break;

            case ExecutionStrategyType.DotNetCoreUnitTestsExecutionStrategy:
                executionStrategy = new DotNetCoreUnitTestsExecutionStrategy(
                    GetCompilerPath,
                    processExecutorFactory,
                    Settings.DotNetCliBaseTimeUsedInMilliseconds,
                    Settings.DotNetCliBaseMemoryUsedInBytes);
                break;

            case ExecutionStrategyType.CSharpUnitTestsExecutionStrategy:
                executionStrategy = new CSharpUnitTestsExecutionStrategy(
                    GetCompilerPath,
                    processExecutorFactory,
                    Settings.NUnitConsoleRunnerPath,
                    Settings.MsBuildBaseTimeUsedInMilliseconds,
                    Settings.MsBuildBaseMemoryUsedInBytes);
                break;

            case ExecutionStrategyType.CSharpProjectTestsExecutionStrategy:
                executionStrategy = new CSharpProjectTestsExecutionStrategy(
                    GetCompilerPath,
                    processExecutorFactory,
                    Settings.NUnitConsoleRunnerPath,
                    Settings.MsBuildBaseTimeUsedInMilliseconds,
                    Settings.MsBuildBaseMemoryUsedInBytes);
                break;

            case ExecutionStrategyType.CSharpPerformanceProjectTestsExecutionStrategy:
                executionStrategy = new CSharpPerformanceProjectTestsExecutionStrategy(
                    GetCompilerPath,
                    processExecutorFactory,
                    Settings.NUnitConsoleRunnerPath,
                    Settings.DotNetCliBaseTimeUsedInMilliseconds,
                    Settings.DotNetCliBaseMemoryUsedInBytes);
                break;

            case ExecutionStrategyType.CSharpAspProjectTestsExecutionStrategy:
                executionStrategy = new CSharpAspProjectTestsExecutionStrategy(
                    GetCompilerPath,
                    processExecutorFactory,
                    Settings.NUnitConsoleRunnerPath,
                    Settings.MsBuildBaseTimeUsedInMilliseconds,
                    Settings.MsBuildBaseMemoryUsedInBytes);
                break;

            case ExecutionStrategyType.DotNetCoreProjectExecutionStrategy:
                executionStrategy = new DotNetCoreProjectExecutionStrategy(
                    GetCompilerPath,
                    processExecutorFactory,
                    Settings.DotNetCliBaseTimeUsedInMilliseconds,
                    Settings.DotNetCliBaseMemoryUsedInBytes);
                break;

            case ExecutionStrategyType.DotNetCoreProjectTestsExecutionStrategy:
                executionStrategy = new DotNetCoreProjectTestsExecutionStrategy(
                    GetCompilerPath,
                    processExecutorFactory,
                    Settings.DotNetCliBaseTimeUsedInMilliseconds,
                    Settings.DotNetCliBaseMemoryUsedInBytes);
                break;

            case ExecutionStrategyType.RubyExecutionStrategy:
                executionStrategy = new RubyExecutionStrategy(
                    processExecutorFactory,
                    Settings.RubyPath,
                    Settings.RubyBaseTimeUsedInMilliseconds,
                    Settings.RubyBaseMemoryUsedInBytes);
                break;

            case ExecutionStrategyType.JavaPreprocessCompileExecuteAndCheck:
                executionStrategy = new JavaPreprocessCompileExecuteAndCheckExecutionStrategy(
                    GetCompilerPath,
                    processExecutorFactory,
                    Settings.JavaExecutablePath,
                    Settings.JavaLibsPath,
                    Settings.JavaBaseTimeUsedInMilliseconds,
                    Settings.JavaBaseMemoryUsedInBytes,
                    Settings.JavaBaseUpdateTimeOffsetInMilliseconds);
                break;

            case ExecutionStrategyType.JavaZipFileCompileExecuteAndCheck:
                executionStrategy = new JavaZipFileCompileExecuteAndCheckExecutionStrategy(
                    GetCompilerPath,
                    processExecutorFactory,
                    Settings.JavaExecutablePath,
                    Settings.JavaLibsPath,
                    Settings.JavaBaseTimeUsedInMilliseconds,
                    Settings.JavaBaseMemoryUsedInBytes);
                break;

            case ExecutionStrategyType.JavaProjectTestsExecutionStrategy:
                executionStrategy = new JavaProjectTestsExecutionStrategy(
                    GetCompilerPath,
                    processExecutorFactory,
                    Settings.JavaExecutablePath,
                    Settings.JavaLibsPath,
                    Settings.JavaBaseTimeUsedInMilliseconds,
                    Settings.JavaBaseMemoryUsedInBytes);
                break;

            case ExecutionStrategyType.JavaUnitTestsExecutionStrategy:
                executionStrategy = new JavaUnitTestsExecutionStrategy(
                    GetCompilerPath,
                    processExecutorFactory,
                    Settings.JavaExecutablePath,
                    Settings.JavaLibsPath,
                    Settings.JavaBaseTimeUsedInMilliseconds,
                    Settings.JavaBaseMemoryUsedInBytes);
                break;

            case ExecutionStrategyType.JavaSpringAndHibernateProjectExecutionStrategy:
                executionStrategy = new JavaSpringAndHibernateProjectExecutionStrategy(
                    GetCompilerPath,
                    processExecutorFactory,
                    Settings.JavaExecutablePath,
                    Settings.JavaLibsPath,
                    Settings.MavenPath,
                    Settings.JavaBaseTimeUsedInMilliseconds,
                    Settings.JavaBaseMemoryUsedInBytes);
                break;

            case ExecutionStrategyType.NodeJsPreprocessExecuteAndCheck:
                executionStrategy = new NodeJsPreprocessExecuteAndCheckExecutionStrategy(
                    processExecutorFactory,
                    Settings.NodeJsExecutablePath,
                    Settings.UnderscoreModulePath,
                    Settings.NodeJsBaseTimeUsedInMilliseconds * 2,
                    Settings.NodeJsBaseMemoryUsedInBytes);
                break;

            case ExecutionStrategyType.NodeJsPreprocessExecuteAndRunUnitTestsWithMocha:
                executionStrategy = new NodeJsPreprocessExecuteAndRunUnitTestsWithMochaExecutionStrategy(
                    processExecutorFactory,
                    Settings.NodeJsExecutablePath,
                    Settings.MochaModulePath,
                    Settings.ChaiModulePath,
                    Settings.SinonModulePath,
                    Settings.SinonChaiModulePath,
                    Settings.UnderscoreModulePath,
                    Settings.NodeJsBaseTimeUsedInMilliseconds,
                    Settings.NodeJsBaseMemoryUsedInBytes);
                break;

            case ExecutionStrategyType.NodeJsZipPreprocessExecuteAndRunUnitTestsWithDomAndMocha:
                executionStrategy = new NodeJsZipPreprocessExecuteAndRunUnitTestsWithDomAndMochaExecutionStrategy(
                    processExecutorFactory,
                    Settings.NodeJsExecutablePath,
                    Settings.MochaModulePath,
                    Settings.ChaiModulePath,
                    Settings.JsDomModulePath,
                    Settings.JQueryModulePath,
                    Settings.HandlebarsModulePath,
                    Settings.SinonModulePath,
                    Settings.SinonChaiModulePath,
                    Settings.UnderscoreModulePath,
                    Settings.BrowserifyModulePath,
                    Settings.BabelifyModulePath,
                    Settings.Es2015ImportPluginPath,
                    Settings.NodeJsBaseTimeUsedInMilliseconds,
                    Settings.NodeJsBaseMemoryUsedInBytes);
                break;

            case ExecutionStrategyType.NodeJsPreprocessExecuteAndRunJsDomUnitTests:
                executionStrategy = new NodeJsPreprocessExecuteAndRunJsDomUnitTestsExecutionStrategy(
                    processExecutorFactory,
                    Settings.NodeJsExecutablePath,
                    Settings.MochaModulePath,
                    Settings.ChaiModulePath,
                    Settings.JsDomModulePath,
                    Settings.JQueryModulePath,
                    Settings.HandlebarsModulePath,
                    Settings.SinonModulePath,
                    Settings.SinonChaiModulePath,
                    Settings.UnderscoreModulePath,
                    Settings.NodeJsBaseTimeUsedInMilliseconds,
                    Settings.NodeJsBaseMemoryUsedInBytes);
                break;

            case ExecutionStrategyType.NodeJsPreprocessExecuteAndRunCodeAgainstUnitTestsWithMochaExecutionStrategy:
                executionStrategy = new NodeJsPreprocessExecuteAndRunCodeAgainstUnitTestsWithMochaExecutionStrategy(
                    processExecutorFactory,
                    Settings.NodeJsExecutablePath,
                    Settings.MochaModulePath,
                    Settings.ChaiModulePath,
                    Settings.JsDomModulePath,
                    Settings.JQueryModulePath,
                    Settings.HandlebarsModulePath,
                    Settings.SinonModulePath,
                    Settings.SinonChaiModulePath,
                    Settings.UnderscoreModulePath,
                    Settings.NodeJsBaseTimeUsedInMilliseconds,
                    Settings.NodeJsBaseMemoryUsedInBytes);
                break;

            case ExecutionStrategyType.NodeJsExecuteAndRunAsyncJsDomTestsWithReactExecutionStrategy:
                executionStrategy = new NodeJsExecuteAndRunAsyncJsDomTestsWithReactExecutionStrategy(
                    processExecutorFactory,
                    Settings.NodeJsExecutablePath,
                    Settings.MochaModulePath,
                    Settings.ChaiModulePath,
                    Settings.JsDomModulePath,
                    Settings.JQueryModulePath,
                    Settings.HandlebarsModulePath,
                    Settings.SinonJsDomModulePath,
                    Settings.SinonModulePath,
                    Settings.SinonChaiModulePath,
                    Settings.UnderscoreModulePath,
                    Settings.BabelCoreModulePath,
                    Settings.ReactJsxPluginPath,
                    Settings.ReactModulePath,
                    Settings.ReactDomModulePath,
                    Settings.NodeFetchModulePath,
                    Settings.NodeJsBaseTimeUsedInMilliseconds,
                    Settings.NodeJsBaseMemoryUsedInBytes);
                break;

            case ExecutionStrategyType.NodeJsZipExecuteHtmlAndCssStrategy:
                executionStrategy = new NodeJsZipExecuteHtmlAndCssStrategy(
                    processExecutorFactory,
                    Settings.NodeJsExecutablePath,
                    Settings.MochaModulePath,
                    Settings.ChaiModulePath,
                    Settings.SinonModulePath,
                    Settings.SinonChaiModulePath,
                    Settings.JsDomModulePath,
                    Settings.JQueryModulePath,
                    Settings.UnderscoreModulePath,
                    Settings.BootstrapModulePath,
                    Settings.BootstrapCssPath,
                    Settings.NodeJsBaseTimeUsedInMilliseconds,
                    Settings.NodeJsBaseMemoryUsedInBytes);
                break;

            case ExecutionStrategyType.PythonExecuteAndCheck:
                executionStrategy = new PythonExecuteAndCheckExecutionStrategy(
                    processExecutorFactory,
                    Settings.PythonExecutablePath,
                    Settings.PythonBaseTimeUsedInMilliseconds,
                    Settings.PythonBaseMemoryUsedInBytes);
                break;

            case ExecutionStrategyType.PythonUnitTests:
                executionStrategy = new PythonUnitTestsExecutionStrategy(
                    processExecutorFactory,
                    Settings.PythonExecutablePath,
                    Settings.PythonBaseTimeUsedInMilliseconds,
                    Settings.PythonBaseMemoryUsedInBytes);
                break;

            case ExecutionStrategyType.PythonCodeExecuteAgainstUnitTests:
                executionStrategy = new PythonCodeExecuteAgainstUnitTestsExecutionStrategy(
                    processExecutorFactory,
                    Settings.PythonExecutablePath,
                    Settings.PythonBaseTimeUsedInMilliseconds,
                    Settings.PythonBaseMemoryUsedInBytes);
                break;

            case ExecutionStrategyType.PythonProjectTests:
                executionStrategy = new PythonProjectTestsExecutionStrategy(
                    processExecutorFactory,
                    Settings.PythonExecutablePath,
                    Settings.PythonBaseTimeUsedInMilliseconds,
                    Settings.PythonBaseMemoryUsedInBytes);
                break;

            case ExecutionStrategyType.PythonProjectUnitTests:
                executionStrategy = new PythonProjectUnitTestsExecutionStrategy(
                    processExecutorFactory,
                    Settings.PythonExecutablePath,
                    Settings.PythonBaseTimeUsedInMilliseconds,
                    Settings.PythonBaseMemoryUsedInBytes);
                break;

            case ExecutionStrategyType.PhpProjectExecutionStrategy:
                executionStrategy = new PhpProjectExecutionStrategy(
                    processExecutorFactory,
                    Settings.PhpCliExecutablePath,
                    Settings.PhpCliBaseTimeUsedInMilliseconds,
                    Settings.PhpCliBaseMemoryUsedInBytes);
                break;

            case ExecutionStrategyType.PhpProjectWithDbExecutionStrategy:
                executionStrategy = new PhpProjectWithDbExecutionStrategy(
                    processExecutorFactory,
                    Settings.PhpCliExecutablePath,
                    Settings.MySqlSysDbConnectionString,
                    Settings.MySqlRestrictedUserId,
                    Settings.MySqlRestrictedUserPassword,
                    Settings.PhpCliBaseTimeUsedInMilliseconds,
                    Settings.PhpCliBaseMemoryUsedInBytes);
                break;

            case ExecutionStrategyType.PhpCgiExecuteAndCheck:
                executionStrategy = new PhpCgiExecuteAndCheckExecutionStrategy(
                    processExecutorFactory,
                    Settings.PhpCgiExecutablePath,
                    Settings.PhpCgiBaseTimeUsedInMilliseconds,
                    Settings.PhpCgiBaseMemoryUsedInBytes);
                break;

            case ExecutionStrategyType.PhpCliExecuteAndCheck:
                executionStrategy = new PhpCliExecuteAndCheckExecutionStrategy(
                    processExecutorFactory,
                    Settings.PhpCliExecutablePath,
                    Settings.PhpCliBaseTimeUsedInMilliseconds,
                    Settings.PhpCliBaseMemoryUsedInBytes);
                break;

            case ExecutionStrategyType.SolidityCompileDeployAndRunUnitTestsExecutionStrategy:
                executionStrategy = new SolidityCompileDeployAndRunUnitTestsExecutionStrategy(
                    GetCompilerPath,
                    processExecutorFactory,
                    Settings.NodeJsExecutablePath,
                    Settings.GanacheCliNodeExecutablePath,
                    Settings.TruffleCliNodeExecutablePath,
                    portNumber,
                    Settings.SolidityBaseTimeUsedInMilliseconds,
                    Settings.SolidityBaseMemoryUsedInBytes);
                break;

            case ExecutionStrategyType.SqlServerLocalDbPrepareDatabaseAndRunQueries:
                executionStrategy = new SqlServerLocalDbPrepareDatabaseAndRunQueriesExecutionStrategy(
                    Settings.SqlServerLocalDbMasterDbConnectionString,
                    Settings.SqlServerLocalDbRestrictedUserId,
                    Settings.SqlServerLocalDbRestrictedUserPassword);
                break;

            case ExecutionStrategyType.SqlServerLocalDbRunQueriesAndCheckDatabase:
                executionStrategy = new SqlServerLocalDbRunQueriesAndCheckDatabaseExecutionStrategy(
                    Settings.SqlServerLocalDbMasterDbConnectionString,
                    Settings.SqlServerLocalDbRestrictedUserId,
                    Settings.SqlServerLocalDbRestrictedUserPassword);
                break;

            case ExecutionStrategyType.SqlServerLocalDbRunSkeletonRunQueriesAndCheckDatabase:
                executionStrategy = new SqlServerLocalDbRunSkeletonRunQueriesAndCheckDatabaseExecutionStrategy(
                    Settings.SqlServerLocalDbMasterDbConnectionString,
                    Settings.SqlServerLocalDbRestrictedUserId,
                    Settings.SqlServerLocalDbRestrictedUserPassword);
                break;

            case ExecutionStrategyType.SqlServerSingleDatabasePrepareDatabaseAndRunQueries:
                executionStrategy = new SqlServerSingleDatabasePrepareDatabaseAndRunQueriesExecutionStrategy(
                    Settings.SqlServerLocalDbMasterDbConnectionString,
                    Settings.SqlServerLocalDbRestrictedUserId,
                    Settings.SqlServerLocalDbRestrictedUserPassword,
                    submissionProcessorIdentifier);
                break;

            case ExecutionStrategyType.SqlServerSingleDatabaseRunQueriesAndCheckDatabase:
                executionStrategy = new SqlServerSingleDatabaseRunQueriesAndCheckDatabaseExecutionStrategy(
                    Settings.SqlServerLocalDbMasterDbConnectionString,
                    Settings.SqlServerLocalDbRestrictedUserId,
                    Settings.SqlServerLocalDbRestrictedUserPassword,
                    submissionProcessorIdentifier);
                break;

            case ExecutionStrategyType.SqlServerSingleDatabaseRunSkeletonRunQueriesAndCheckDatabase:
                executionStrategy = new SqlServerSingleDatabaseRunSkeletonRunQueriesAndCheckDatabaseExecutionStrategy(
                    Settings.SqlServerLocalDbMasterDbConnectionString,
                    Settings.SqlServerLocalDbRestrictedUserId,
                    Settings.SqlServerLocalDbRestrictedUserPassword,
                    submissionProcessorIdentifier);
                break;

            case ExecutionStrategyType.MySqlPrepareDatabaseAndRunQueries:
                executionStrategy = new MySqlPrepareDatabaseAndRunQueriesExecutionStrategy(
                    Settings.MySqlSysDbConnectionString,
                    Settings.MySqlRestrictedUserId,
                    Settings.MySqlRestrictedUserPassword);
                break;

            case ExecutionStrategyType.MySqlRunQueriesAndCheckDatabase:
                executionStrategy = new MySqlRunQueriesAndCheckDatabaseExecutionStrategy(
                    Settings.MySqlSysDbConnectionString,
                    Settings.MySqlRestrictedUserId,
                    Settings.MySqlRestrictedUserPassword);
                break;

            case ExecutionStrategyType.MySqlRunSkeletonRunQueriesAndCheckDatabase:
                executionStrategy = new MySqlRunSkeletonRunQueriesAndCheckDatabaseExecutionStrategy(
                    Settings.MySqlSysDbConnectionString,
                    Settings.MySqlRestrictedUserId,
                    Settings.MySqlRestrictedUserPassword);
                break;

            case ExecutionStrategyType.DoNothing:
                executionStrategy = new DoNothingExecutionStrategy();
                break;

            case ExecutionStrategyType.RemoteExecution:
                executionStrategy = new RemoteExecutionStrategy();
                break;

            case ExecutionStrategyType.CheckOnly:
                executionStrategy = new CheckOnlyExecutionStrategy(processExecutorFactory, 0, 0);
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }

            return(executionStrategy);
        }