Exemplo n.º 1
0
        private static async Task StartSqlServerContainer(string password, int port)
        {
            ProcessStartInfo startInfo = new ProcessStartInfo(
                DOCKER_PROCESS,
                $"run --rm -e \"ACCEPT_EULA=Y\" -e \"SA_PASSWORD={password}\" -e \"MSSQL_PID=Express\" -e \"TZ=Europe/London\" -p{port}:1433 -d --name={MS_SQL_CONTAINER_NAME} mcr.microsoft.com/mssql/server:latest");
            Process startProcess = Process.Start(startInfo);
            await startProcess.WaitForExitAsync();

            string connectionString = MsSqlTestHelper.GetMsSqlConnectionString();

            while (true)
            {
                try
                {
                    MsSqlTestHelper.OpenConnection(connectionString);
                }
                catch
                {
                    Console.WriteLine("Waiting for My SQL to initialise...");
                    Thread.Sleep(5000);
                    continue;
                }

                break;
            }
        }