File tree Expand file tree Collapse file tree 2 files changed +35
-1
lines changed
Ductus.FluentDocker.Tests/FluentApiTests
Ductus.FluentDocker/Builders Expand file tree Collapse file tree 2 files changed +35
-1
lines changed Original file line number Diff line number Diff line change @@ -191,6 +191,40 @@ public void ImplicitPortMappingShouldWork()
191191 }
192192 }
193193
194+ [ TestMethod ]
195+ [ TestCategory ( "CI" ) ]
196+ public void FullImplicitPortMappingShouldWork ( )
197+ {
198+ using (
199+ var container =
200+ Fd . UseContainer ( )
201+ . UseImage ( "postgres:9.6-alpine" )
202+ . ExposeAllPorts ( )
203+ . WithEnvironment ( "POSTGRES_PASSWORD=mysecretpassword" )
204+ . Build ( )
205+ . Start ( ) )
206+ {
207+ var endpoint = container . ToHostExposedEndpoint ( "5432/tcp" ) ;
208+ AreNotEqual ( 0 , endpoint . Port ) ;
209+ }
210+ }
211+
212+ [ TestMethod ]
213+ [ TestCategory ( "CI" ) ]
214+ public void ExposeAllPortsIsMutuallyExclusiveWithExposePort ( )
215+ {
216+ var exception = ThrowsException < FluentDockerNotSupportedException > ( ( ) => Fd . UseContainer ( ) . ExposePort ( 5432 ) . ExposeAllPorts ( ) ) ;
217+ AreEqual ( "ExposeAllPorts is mutually exclusive with ExposePort methods. Do not call ExposePort if you want to expose all ports." , exception . Message ) ;
218+ }
219+
220+ [ TestMethod ]
221+ [ TestCategory ( "CI" ) ]
222+ public void ExposePortIsMutuallyExclusiveWithExposeAllPorts ( )
223+ {
224+ var exception = ThrowsException < FluentDockerNotSupportedException > ( ( ) => Fd . UseContainer ( ) . ExposeAllPorts ( ) . ExposePort ( 5432 ) ) ;
225+ AreEqual ( "ExposePort is mutually exclusive with ExposeAllPorts methods. Do not call ExposeAllPorts if you want to explicitly expose ports." , exception . Message ) ;
226+ }
227+
194228 [ TestMethod ]
195229 [ TestCategory ( "CI" ) ]
196230 public void WaitForPortShallWork ( )
Original file line number Diff line number Diff line change @@ -358,7 +358,7 @@ private void EnsurePublishAllPortsIsFalse()
358358
359359 private void EnsurePortMappingsIsEmpty ( )
360360 {
361- if ( _config . CreateParams . PortMappings . Any ( ) )
361+ if ( _config . CreateParams . PortMappings ? . Any ( ) == true )
362362 {
363363 throw new FluentDockerNotSupportedException ( $ "{ nameof ( ExposeAllPorts ) } is mutually exclusive with { nameof ( ExposePort ) } methods. " +
364364 $ "Do not call { nameof ( ExposePort ) } if you want to expose all ports.") ;
You can’t perform that action at this time.
0 commit comments