11using CourseLibrary . API ;
2- using DotNet . Testcontainers . Builders ;
3- using DotNet . Testcontainers . Configurations ;
4- using DotNet . Testcontainers . Containers ;
52using Microsoft . AspNetCore . Hosting ;
63using Microsoft . AspNetCore . Mvc . Testing ;
74using Microsoft . AspNetCore . TestHost ;
107using Microsoft . Extensions . DependencyInjection . Extensions ;
118using Microsoft . Extensions . Hosting ;
129using Microsoft . Extensions . Logging ;
10+ using Testcontainers . MsSql ;
1311
1412namespace CourseLibrary . Tests . Integration ;
1513
1614public class IntegrationTestFactory : WebApplicationFactory < IApiMarker > , IAsyncLifetime
1715{
18- private readonly TestcontainerDatabase _dbContainer = new TestcontainersBuilder < MsSqlTestcontainer > ( )
19- . WithDatabase ( new MsSqlTestcontainerConfiguration
20- {
21- Password = "p@ssword123456" ,
22- } )
16+ private readonly MsSqlContainer _dbContainer ;
17+ public IntegrationTestFactory ( )
18+ {
19+ _dbContainer = new MsSqlBuilder ( )
2320 . WithCleanUp ( true )
2421 . Build ( ) ;
22+ }
2523
2624 protected override void ConfigureWebHost ( IWebHostBuilder builder )
2725 {
@@ -38,7 +36,7 @@ protected override void ConfigureWebHost(IWebHostBuilder builder)
3836 services . RemoveAll ( typeof ( IHostedService ) ) ;
3937 } ) ;
4038
41- SqlConnectionStringBuilder sqlConnectionStringBuilder = new ( _dbContainer . ConnectionString )
39+ SqlConnectionStringBuilder sqlConnectionStringBuilder = new ( _dbContainer . GetConnectionString ( ) )
4240 {
4341 TrustServerCertificate = true ,
4442 InitialCatalog = "CourseLibrary"
0 commit comments