public async Task InitializeAsync()
        {
            await _environment.Up();

            var mssql = _environment.GetContainer <MssqlContainer>(ContainerName);

            _connectionString = mssql.GetConnectionString();
        }
        public async Task OneTimeSetup()
        {
            var environmentBuilder = new DockerEnvironmentBuilder();

            _dockerEnvironment = PrepareDockerEnvironment(environmentBuilder);
            await _dockerEnvironment.Up();

            var connectionString = _dockerEnvironment.GetContainer <MssqlContainer>("testDb").GetConnectionString();

            DbContext = new PizzaContext(connectionString);
            await DbContext.Database.EnsureCreatedAsync();
        }
        public async Task InitializeAsync()
        {
            await _environment.Up();

            var mongoContainer = _environment.GetContainer <MongoContainer>("mongo");

            var mongoClient = _configuration.GetMongoClient(mongoContainer.GetConnectionString());

            Collection = mongoClient.GetDatabase(_configuration.DatabaseName)
                         .GetCollection <TDocument>(_configuration.CollectionName);

            await _configuration.InitializeAsync(Collection);
        }
Example #4
0
        public async Task InitializeAsync()
        {
            // Docker environment seutup.
            _environment = CreateTestEnvironmentBuilder().Build();
            await _environment.Up();

            // API Test host setup
            var mongoContainer = _environment.GetContainer <MongoContainer>("mongo");

            _host = await CreateHostBuilder(mongoContainer).StartAsync();

            TestClient = _host.GetTestClient();

            await OnInitialized(mongoContainer);
        }
Example #5
0
        public async Task InitializeAsync()
        {
            DockerEnvironmentBuilder builder = new DockerEnvironmentBuilder();

            m_environment = builder
                            .AddMssqlContainer(SqlContainerName, Guid.NewGuid().ToString())
                            .Build();

            await m_environment.Up();

            m_mssqlContainer   = m_environment.GetContainer <MssqlContainer>(SqlContainerName);
            m_connectionString = m_mssqlContainer.GetConnectionString();

            Initialize();
        }
        public async Task GlobalSetup()
        {
            _env = new DockerEnvironmentBuilder().SetName("efcore5_tests").AddPostgresContainer("postgres").Build();
            await _env.Up();

            var container = _env.GetContainer <PostgresContainer>("postgres");

            _connectionString = container.GetConnectionString();

            using (var context = new BloggingContext(_connectionString))
            {
                context.Database.EnsureCreated();

                context.AddRange(Enumerable.Range(0, RowsCount).Select(i => new Blog
                {
                    Url         = $"1{i}3456{i}8",
                    Name        = $"Bobby-{i}-Johns",
                    CreatedDate = DateTime.UtcNow.AddDays(new Random().Next(-10, 10)),
                    UpdatedDate = DateTime.UtcNow
                }).ToList());

                context.SaveChanges();
            }
        }