1+ using System . Linq ;
2+ using DotNet . Testcontainers . Configurations ;
3+
14namespace Testcontainers . PostgreSql ;
25
36public abstract class PostgreSqlContainerTest ( PostgreSqlContainerTest . PostgreSqlDefaultFixture fixture )
47{
58 // # --8<-- [start:UsePostgreSqlContainer]
9+ #if ADONET_CLIENT
610 [ Fact ]
711 [ Trait ( nameof ( DockerCli . DockerPlatform ) , nameof ( DockerCli . DockerPlatform . Linux ) ) ]
812 public void ConnectionStateReturnsOpen ( )
@@ -16,6 +20,7 @@ public void ConnectionStateReturnsOpen()
1620 // Then
1721 Assert . Equal ( ConnectionState . Open , connection . State ) ;
1822 }
23+ #endif
1924
2025 [ Fact ]
2126 [ Trait ( nameof ( DockerCli . DockerPlatform ) , nameof ( DockerCli . DockerPlatform . Linux ) ) ]
@@ -34,6 +39,19 @@ public async Task ExecScriptReturnsSuccessful()
3439 }
3540 // # --8<-- [end:UsePostgreSqlContainer]
3641
42+ [ Fact ]
43+ public void WaitStrategyUsed ( )
44+ {
45+ PostgreSqlConfiguration configuration = fixture . Container . AsDynamic ( ) . _configuration ;
46+ var waitStrategy = configuration . WaitStrategies . Last ( ) ;
47+ IWaitUntil waitUntil = DynamicHelper . Unwrap ( waitStrategy . AsDynamic ( ) . _waitUntil ) ;
48+ #if ADONET_CLIENT
49+ Assert . Equal ( "UntilDatabaseIsAvailable" , waitUntil . GetType ( ) . Name ) ;
50+ #else
51+ Assert . Equal ( "Testcontainers.PostgreSql.PostgreSqlBuilder+WaitUntil" , waitUntil . GetType ( ) . FullName ) ;
52+ #endif
53+ }
54+
3755 public sealed class ReuseContainerTest : IClassFixture < PostgreSqlDefaultFixture > , IDisposable
3856 {
3957 private readonly CancellationTokenSource _cts = new CancellationTokenSource ( TimeSpan . FromMinutes ( 1 ) ) ;
@@ -66,26 +84,32 @@ await _fixture.Container.StartAsync(_cts.Token)
6684 }
6785 }
6886
87+ #if ADONET_CLIENT
6988 public class PostgreSqlDefaultFixture ( IMessageSink messageSink )
7089 : DbContainerFixture < PostgreSqlBuilder , PostgreSqlContainer > ( messageSink )
7190 {
7291 public override DbProviderFactory DbProviderFactory
7392 => NpgsqlFactory . Instance ;
7493 }
94+ #else
95+ public class PostgreSqlDefaultFixture ( IMessageSink messageSink )
96+ : ContainerFixture < PostgreSqlBuilder , PostgreSqlContainer > ( messageSink ) ;
97+ #endif
7598
7699 [ UsedImplicitly ]
77- public class PostgreSqlWaitForDatabaseFixture ( IMessageSink messageSink )
78- : PostgreSqlDefaultFixture ( messageSink )
100+ public class PostgreSql92Fixture ( IMessageSink messageSink ) : PostgreSqlDefaultFixture ( messageSink )
79101 {
80102 protected override PostgreSqlBuilder Configure ( PostgreSqlBuilder builder )
81- => builder . WithWaitStrategy ( Wait . ForUnixContainer ( ) . UntilDatabaseIsAvailable ( DbProviderFactory ) ) ;
103+ => builder . WithImage ( "postgres:9.2" ) ;
82104 }
83105
84106 [ UsedImplicitly ]
85107 public sealed class PostgreSqlDefaultConfiguration ( PostgreSqlDefaultFixture fixture )
86108 : PostgreSqlContainerTest ( fixture ) , IClassFixture < PostgreSqlDefaultFixture > ;
87109
110+ #if ADONET_CLIENT
88111 [ UsedImplicitly ]
89- public sealed class PostgreSqlWaitForDatabaseConfiguration( PostgreSqlWaitForDatabaseFixture fixture )
90- : PostgreSqlContainerTest ( fixture ) , IClassFixture < PostgreSqlWaitForDatabaseFixture > ;
112+ public sealed class PostgreSql92Configuration( PostgreSql92Fixture fixture )
113+ : PostgreSqlContainerTest ( fixture ) , IClassFixture < PostgreSql92Fixture > ;
114+ #endif
91115}
0 commit comments