@@ -4,11 +4,18 @@ public sealed class ConnectionStringProviderTests : IAsyncLifetime
44{
55 private const string ExpectedConnectionString = "connection string" ;
66
7- private readonly IContainer _container = new ContainerBuilder ( )
8- . WithImage ( CommonImages . Alpine )
9- . WithCommand ( CommonCommands . SleepInfinity )
10- . WithConnectionStringProvider ( new ConnectionStringProvider ( ) )
11- . Build ( ) ;
7+ private readonly ConnectionStringProvider _connectionStringProvider = new ConnectionStringProvider ( ) ;
8+
9+ private readonly IContainer _container ;
10+
11+ public ConnectionStringProviderTests ( )
12+ {
13+ _container = new ContainerBuilder ( )
14+ . WithImage ( CommonImages . Alpine )
15+ . WithCommand ( CommonCommands . SleepInfinity )
16+ . WithConnectionStringProvider ( _connectionStringProvider )
17+ . Build ( ) ;
18+ }
1219
1320 public async ValueTask InitializeAsync ( )
1421 {
@@ -25,16 +32,20 @@ await _container.DisposeAsync()
2532 [ Fact ]
2633 public void GetConnectionStringReturnsExpectedValue ( )
2734 {
35+ Assert . True ( _connectionStringProvider . IsConfigured , "Configure should have been called during container startup." ) ;
2836 Assert . Equal ( ExpectedConnectionString , _container . GetConnectionString ( ) ) ;
2937 Assert . Equal ( ExpectedConnectionString , _container . GetConnectionString ( "name" ) ) ;
3038 }
3139
3240 private sealed class ConnectionStringProvider : IConnectionStringProvider < IContainer , IContainerConfiguration >
3341 {
42+ public bool IsConfigured { get ; private set ; }
43+
3444 public void Configure ( IContainer container , IContainerConfiguration configuration )
3545 {
3646 Assert . NotNull ( container ) ;
3747 Assert . NotNull ( configuration ) ;
48+ IsConfigured = true ;
3849 }
3950
4051 public string GetConnectionString ( ConnectionMode connectionMode = ConnectionMode . Host )
0 commit comments