public void ExposePortsAddsPortsToExisting(int?internalPort1, int?externalPort1, int?internalPort2, int?externalPort2)
        {
            // Arrange
            var sut = new StartContainerOptions();

            sut.ExposePort(42, 42);

            var portMappings = new List <DockerPortMapping>
            {
                GetPortMapping(internalPort1, externalPort1),
                GetPortMapping(internalPort2, externalPort2)
            }.Where(p => p != null);

            var expectedMappings = new List <DockerPortMapping> {
                new DockerPortMapping(42, 42)
            };

            expectedMappings.AddRange(portMappings);

            // Act
            sut.ExposePorts(portMappings);

            // Assert
            sut.DockerPortMappings.Should().BeEquivalentTo(expectedMappings);
        }
Beispiel #2
0
        public void WithOptionsPortMappings_AddsArgumentPerPort(int?internalPort1, int?externalPort1, int?internalPort2, int?externalPort2, string expectedPortArguments)
        {
            //Arrange
            var options = new StartContainerOptions();

            if (internalPort1.HasValue && externalPort1.HasValue)
            {
                options.ExposePort(internalPort1.Value, externalPort1.Value);
            }

            if (internalPort2.HasValue && externalPort2.HasValue)
            {
                options.ExposePort(internalPort2.Value, externalPort2.Value);
            }

            // Act
            var result = Dockhand.Client.DockerCommands.Image.RunContainer(ImageId, options);

            // Assert
            result.Should().Contain($"docker run -d {expectedPortArguments}{ImageId}");
        }
        public void ExposePortAddsPort()
        {
            // Arrange
            var internalPort = 443;
            var externalPort = 5003;
            var sut          = new StartContainerOptions();

            var expectedMappings = new [] { GetPortMapping(internalPort, externalPort) };

            // Act
            sut.ExposePort(443, 5003);

            // Assert
            sut.DockerPortMappings.Should().BeEquivalentTo(expectedMappings);
        }
        public void ExposePortAddsPortToExisting()
        {
            // Arrange
            var internalPort = 43;
            var externalPort = 44;
            var sut          = new StartContainerOptions();

            sut.ExposePorts(new [] { GetPortMapping(42, 42) });

            var expectedMappings = new [] { GetPortMapping(42, 42), GetPortMapping(internalPort, externalPort) };

            // Act
            sut.ExposePort(internalPort, externalPort);

            // Assert
            sut.DockerPortMappings.Should().BeEquivalentTo(expectedMappings);
        }