1+ using DotNet . Testcontainers . Builders ;
2+
13namespace BuildingBlocks . TestBase ;
24
35using Testcontainers . EventStoreDb ;
@@ -18,15 +20,19 @@ static TestContainers()
1820 {
1921 var configuration = ConfigurationHelper . GetConfiguration ( ) ;
2022
21- RabbitMqContainerConfiguration =
22- configuration . GetOptions < RabbitMqContainerOptions > ( nameof ( RabbitMqContainerOptions ) ) ;
23- PostgresContainerConfiguration =
24- configuration . GetOptions < PostgresContainerOptions > ( nameof ( PostgresContainerOptions ) ) ;
25- PostgresPersistContainerConfiguration =
26- configuration . GetOptions < PostgresPersistContainerOptions > ( nameof ( PostgresPersistContainerOptions ) ) ;
23+ RabbitMqContainerConfiguration = configuration . GetOptions < RabbitMqContainerOptions > (
24+ nameof ( RabbitMqContainerOptions )
25+ ) ;
26+ PostgresContainerConfiguration = configuration . GetOptions < PostgresContainerOptions > (
27+ nameof ( PostgresContainerOptions )
28+ ) ;
29+ PostgresPersistContainerConfiguration = configuration . GetOptions < PostgresPersistContainerOptions > (
30+ nameof ( PostgresPersistContainerOptions )
31+ ) ;
2732 MongoContainerConfiguration = configuration . GetOptions < MongoContainerOptions > ( nameof ( MongoContainerOptions ) ) ;
28- EventStoreContainerConfiguration =
29- configuration . GetOptions < EventStoreContainerOptions > ( nameof ( EventStoreContainerOptions ) ) ;
33+ EventStoreContainerConfiguration = configuration . GetOptions < EventStoreContainerOptions > (
34+ nameof ( EventStoreContainerOptions )
35+ ) ;
3036 }
3137
3238 public static PostgreSqlContainer PostgresTestContainer ( )
@@ -81,25 +87,33 @@ public static MongoDbContainer MongoTestContainer()
8187
8288 public static RabbitMqContainer RabbitMqTestContainer ( )
8389 {
84- var baseBuilder = new RabbitMqBuilder ( )
90+ var builder = new RabbitMqBuilder ( )
8591 . WithUsername ( RabbitMqContainerConfiguration . UserName )
8692 . WithPassword ( RabbitMqContainerConfiguration . Password )
87- . WithLabel ( "Key" , "Value" ) ;
88-
89- var builder = baseBuilder
9093 . WithImage ( RabbitMqContainerConfiguration . ImageName )
9194 . WithName ( RabbitMqContainerConfiguration . Name )
9295 . WithPortBinding ( RabbitMqContainerConfiguration . ApiPort , true )
9396 . WithPortBinding ( RabbitMqContainerConfiguration . Port , true )
97+ . WithWaitStrategy (
98+ Wait . ForUnixContainer ( )
99+ . UntilHttpRequestIsSucceeded ( request =>
100+ request
101+ . ForPort ( ( ushort ) RabbitMqContainerConfiguration . ApiPort )
102+ . ForPath ( "/api/overview" )
103+ . WithBasicAuthentication (
104+ RabbitMqContainerConfiguration . UserName ,
105+ RabbitMqContainerConfiguration . Password
106+ )
107+ )
108+ )
94109 . Build ( ) ;
95110
96111 return builder ;
97112 }
98113
99114 public static EventStoreDbContainer EventStoreTestContainer ( )
100115 {
101- var baseBuilder = new EventStoreDbBuilder ( )
102- . WithLabel ( "Key" , "Value" ) ;
116+ var baseBuilder = new EventStoreDbBuilder ( ) . WithLabel ( "Key" , "Value" ) ;
103117
104118 var builder = baseBuilder
105119 . WithImage ( EventStoreContainerConfiguration . ImageName )
0 commit comments