Пример #1
0
        public static async Task <TestExchangeDbContextProvider> GetInstanceAsync()
        {
            var testContainer = new TestcontainersBuilder <PostgreSqlTestcontainer>()
                                .WithDatabase(new PostgreSqlTestcontainerConfiguration
            {
                Database = "db",
                Username = "******",
                Password = "******",
            }).Build();
            await testContainer.StartAsync();

            return(new TestExchangeDbContextProvider(testContainer));
        }
Пример #2
0
            public async Task UnsafeDisposable()
            {
                // Given
                IDockerContainer testcontainer = new TestcontainersBuilder <TestcontainersContainer>()
                                                 .WithImage("alpine")
                                                 .WithLabel(typeof(TestcontainersContainer).Assembly.GetName().Name, nameof(this.UnsafeDisposable))
                                                 .Build();

                // When
                // Then
                await testcontainer.StartAsync();

                await testcontainer.StopAsync();

                await testcontainer.DisposeAsync();
            }
Пример #3
0
        public MySqlTestcontainer CreateMySqlContainer()
        {
            var mySqlTestcontainer = new TestcontainersBuilder <MySqlTestcontainer>()
                                     .WithDatabase(new MySqlTestcontainerConfiguration("mysql:5.7")
            {
                Database = "db_order_it",
                Username = "******",
                Password = "******"
            })
                                     .WithExposedPort(3306)
                                     .Build();

            mySqlTestcontainer.StartAsync().ConfigureAwait(false).GetAwaiter().GetResult();

            return(mySqlTestcontainer);
        }
Пример #4
0
        public TestcontainersContainer CreateMySqlContainer()
        {
            var container = new TestcontainersBuilder <TestcontainersContainer>()
                            .WithImage("node:6.11-slim")
                            .WithWorkingDirectory("/mocks")
                            .WithMount("../../../../dependencies/stubby/", "/mocks")
                            .WithEntrypoint("/bin/sh", "-c", "npm install -g [email protected] && stubby -d /mocks/init.yml -s 8882 -a 8889 -w")
                            .WithCleanUp(false)
                            .WithExposedPort("8882")
                            .WithCleanUp(true)
                            .WithWaitStrategy(Wait.ForUnixContainer().UntilPortIsAvailable(8882))
                            .WithPortBinding("8882", true)
                            .Build();

            container.StartAsync().ConfigureAwait(false).GetAwaiter().GetResult();

            return(container);
        }