public async Task SetupDatabaseAsync()
        {
            await SqlServerContainer.StartAsync();

            var settings = TestConfiguration.GetConfiguration();

            await DbHelper.EnsureStarted(settings.DbServerConnectionString, TimeSpan.FromSeconds(60));

            await DbHelper.ReCreateDatabase();
        }
Exemplo n.º 2
0
        public async Task <(string, DbConnection)> StartAsync()
        {
            var dockerUri = IDatabaseController.GetDockerUri();

            _dockerClient = new DockerClientConfiguration(
                new Uri(dockerUri))
                            .CreateClient();

            DockerContainerBase.CleanupOrphanedContainersAsync(_dockerClient).Wait(Timeout * 500);

            _sqlServerContainer = new SqlServerContainer(Port, Password);

            await _sqlServerContainer.StartAsync(_dockerClient, Timeout);

            var connectionString = _sqlServerContainer.GetConnectionString(DatabaseName);

            //TODO: use logger
            Console.WriteLine($"*** SQL Server database started and the connection string is: \"{connectionString}\"");

            var connection = new SqlConnection(connectionString);

            return(connectionString, connection);
        }