44
55namespace HealthChecks . Oracle . Tests . Functional ;
66
7- public class oracle_healthcheck_should
7+ public class oracle_healthcheck_should ( OracleContainerFixture oracleFixture ) : IClassFixture < OracleContainerFixture >
88{
99 [ Fact ]
1010 public async Task be_healthy_when_oracle_is_available ( )
1111 {
12- var connectionString = "Data Source=localhost:1521/XEPDB1;User Id=system;Password=oracle" ;
12+ string connectionString = oracleFixture . GetConnectionString ( ) ;
1313
1414 var webHostBuilder = new WebHostBuilder ( )
1515 . ConfigureServices ( services =>
@@ -34,13 +34,15 @@ public async Task be_healthy_when_oracle_is_available()
3434 [ Fact ]
3535 public async Task be_unhealthy_when_oracle_is_not_available ( )
3636 {
37- var connectionString = "Data Source=255.255.255.255:1521/XEPDB1;User Id=system;Password=oracle" ;
37+ var connectionStringBuilder = oracleFixture . GetConnectionStringBuilder ( ) ;
38+
39+ connectionStringBuilder . DataSource = "invalid" ;
3840
3941 var webHostBuilder = new WebHostBuilder ( )
4042 . ConfigureServices ( services =>
4143 {
4244 services . AddHealthChecks ( )
43- . AddOracle ( connectionString , tags : [ "oracle" ] ) ;
45+ . AddOracle ( connectionStringBuilder . ConnectionString , tags : [ "oracle" ] ) ;
4446 } )
4547 . Configure ( app =>
4648 {
@@ -58,7 +60,8 @@ public async Task be_unhealthy_when_oracle_is_not_available()
5860 [ Fact ]
5961 public async Task be_unhealthy_when_sql_query_is_not_valid ( )
6062 {
61- var connectionString = "Data Source=localhost:1521/XEPDB1;User Id=system;Password=oracle" ;
63+ string connectionString = oracleFixture . GetConnectionString ( ) ;
64+
6265 var webHostBuilder = new WebHostBuilder ( )
6366 . ConfigureServices ( services =>
6467 {
@@ -82,7 +85,7 @@ public async Task be_unhealthy_when_sql_query_is_not_valid()
8285 public async Task be_healthy_with_connection_string_factory_when_oracle_is_available ( )
8386 {
8487 bool factoryCalled = false ;
85- string connectionString = "Data Source=localhost:1521/XEPDB1;User Id=system;Password=oracle" ;
88+ string connectionString = oracleFixture . GetConnectionString ( ) ;
8689
8790 var webHostBuilder = new WebHostBuilder ( )
8891 . ConfigureServices ( services =>
@@ -114,8 +117,8 @@ public async Task be_healthy_with_connection_string_factory_when_oracle_is_avail
114117 public async Task be_healthy_with_connection_string_and_credential_when_oracle_is_available ( )
115118 {
116119 bool factoryCalled = false ;
117- string connectionString = "Data Source=localhost:1521/XEPDB1" ;
118- var password = new NetworkCredential ( "system" , "oracle" ) . SecurePassword ;
120+ var connectionStringBuilder = oracleFixture . GetConnectionStringBuilder ( ) ;
121+ var password = new NetworkCredential ( connectionStringBuilder . UserID , connectionStringBuilder . Password ) . SecurePassword ;
119122 password . MakeReadOnly ( ) ;
120123 var credential = new OracleCredential ( "system" , password ) ;
121124
@@ -124,7 +127,7 @@ public async Task be_healthy_with_connection_string_and_credential_when_oracle_i
124127 {
125128 services
126129 . AddHealthChecks ( )
127- . AddOracle ( connectionString , tags : [ "oracle" ] ,
130+ . AddOracle ( $ "DATA SOURCE= { connectionStringBuilder . DataSource } " , tags : [ "oracle" ] ,
128131 configure : options =>
129132 {
130133 factoryCalled = true ;
0 commit comments