コード例 #1
0
        public TestcontainersNetworkTest(NetworkFixture networkFixture)
        {
            var testcontainersBuilder = new TestcontainersBuilder <TestcontainersContainer>()
                                        .WithImage("alpine")
                                        .WithEntrypoint(KeepTestcontainersUpAndRunning.Command)
                                        .WithNetwork(networkFixture.Network.Id, networkFixture.Network.Name);

            this.testcontainer1 = testcontainersBuilder
                                  .WithHostname(nameof(this.testcontainer1))
                                  .WithNetworkAliases(nameof(this.testcontainer1) + AliasSuffix)
                                  .Build();

            this.testcontainer2 = testcontainersBuilder
                                  .WithHostname(nameof(this.testcontainer2))
                                  .WithNetworkAliases(nameof(this.testcontainer2) + AliasSuffix)
                                  .Build();
        }
コード例 #2
0
        public TestcontainersVolumeTest(VolumeFixture volumeFixture)
        {
            var testcontainersBuilder = new TestcontainersBuilder <TestcontainersContainer>()
                                        .WithImage("alpine")
                                        .WithEntrypoint("/bin/sh", "-c")
                                        .WithCommand("touch /tmp/$(uname -n) && tail -f /dev/null")
                                        .WithResourceReaperSessionId(volumeFixture.SessionId)
                                        .WithVolumeMount(volumeFixture.Name, Destination);

            this.testcontainer1 = testcontainersBuilder
                                  .WithHostname(nameof(this.testcontainer1))
                                  .Build();

            this.testcontainer2 = testcontainersBuilder
                                  .WithHostname(nameof(this.testcontainer2))
                                  .Build();
        }