@@ -32,90 +32,76 @@ static TcpDefaultForAzureTest()
3232 builder . ConnectTimeout = 1 ;
3333 }
3434
35- [ ActiveIssue ( 19028 ) ]
3635 [ Fact ]
37- [ PlatformSpecific ( TestPlatforms . Windows ) ] // NP NonAzure connection with no protocol fails correctly on Windows
38- public static void NonAzureNoProtocolConnectionTestOnWindows ( )
36+ public static void NonAzureNoProtocolConnectionTest ( )
3937 {
4038 builder . DataSource = InvalidHostname ;
41- Assert . True ( IsConnectionFailedOn ( builder . ConnectionString , NP ) ) ;
39+ IsConnectionFailedOn ( builder . ConnectionString , null ) ; // Managed and Native SNI have different default protocols for plain server names
4240 }
4341
44-
45- [ Fact ]
46- [ PlatformSpecific ( TestPlatforms . AnyUnix ) ] // TCP NonAzure connection with no protocol fails correctly on Unix
47- public static void NonAzureNoProtocolConnectionTestOnUnix ( )
48- {
49- builder . DataSource = InvalidHostname ;
50- Assert . True ( IsConnectionFailedOn ( builder . ConnectionString , TCP ) ) ;
51- }
52-
53-
5442 [ Fact ]
5543 public static void NonAzureTcpConnectionTest ( )
5644 {
5745 builder . DataSource = "tcp:" + InvalidHostname ;
58- Assert . True ( IsConnectionFailedOn ( builder . ConnectionString , TCP ) ) ;
46+ IsConnectionFailedOn ( builder . ConnectionString , TCP ) ;
5947 }
6048
61-
6249 [ Fact ]
6350 [ PlatformSpecific ( TestPlatforms . Windows ) ] // NP NonAzure connection fails correctly on Windows
6451 public static void NonAzureNpConnectionTest ( )
6552 {
6653 builder . DataSource = "np:\\ \\ " + InvalidHostname + "\\ pipe\\ sql\\ query" ;
67- Assert . True ( IsConnectionFailedOn ( builder . ConnectionString , NP ) ) ;
54+ IsConnectionFailedOn ( builder . ConnectionString , NP ) ;
6855 }
6956
70-
7157 [ Fact ]
7258 [ SkipOnTargetFramework ( TargetFrameworkMonikers . NetFramework ) ]
7359 public static void AzureNoProtocolConnectionTest ( )
7460 {
7561 foreach ( string extension in AzureExtensions )
7662 {
7763 builder . DataSource = InvalidHostname + extension ;
78- Assert . True ( IsConnectionFailedOn ( builder . ConnectionString , TCP ) ) ;
64+ IsConnectionFailedOn ( builder . ConnectionString , TCP ) ;
7965 }
8066 }
8167
82-
8368 [ Fact ]
8469 public static void AzureTcpConnectionTest ( )
8570 {
8671 foreach ( string extension in AzureExtensions )
8772 {
8873 builder . DataSource = "tcp:" + InvalidHostname + extension ;
89- Assert . True ( IsConnectionFailedOn ( builder . ConnectionString , TCP ) ) ;
74+ IsConnectionFailedOn ( builder . ConnectionString , TCP ) ;
9075 }
9176 }
9277
93-
9478 [ Fact ]
9579 [ PlatformSpecific ( TestPlatforms . Windows ) ] // NP Azure connection fails correctly on Windows
9680 public static void AzureNpConnectionTest ( )
9781 {
9882 foreach ( string extension in AzureExtensions )
9983 {
10084 builder . DataSource = "np:\\ \\ " + InvalidHostname + extension + "\\ pipe\\ sql\\ query" ;
101- Assert . True ( IsConnectionFailedOn ( builder . ConnectionString , NP ) ) ;
85+ IsConnectionFailedOn ( builder . ConnectionString , NP ) ;
10286 }
10387 }
10488
105-
106- private static bool IsConnectionFailedOn ( string connString , string protocol )
89+ private static void IsConnectionFailedOn ( string connString , string protocol )
10790 {
10891 Debug . Assert ( ! string . IsNullOrWhiteSpace ( connString ) ) ;
109- Debug . Assert ( ! string . IsNullOrWhiteSpace ( protocol ) ) ;
110- Debug . Assert ( protocol == NP || protocol == TCP ) ;
11192
11293 string errorMessage = Connect ( connString ) ;
11394
114- return errorMessage != null &&
115- errorMessage . Contains ( ErrorMessage ) &&
116- errorMessage . Contains ( String . Format ( "provider: {0}, error" , protocol ) ) ;
117- }
95+ Assert . True ( errorMessage != null , "Did not receive any error message" ) ;
96+ Assert . True ( errorMessage . Contains ( ErrorMessage ) , string . Format ( "Expected error message {0}, but received: {1}" , ErrorMessage , errorMessage ) ) ;
11897
98+ if ( protocol != null )
99+ {
100+ Assert . True (
101+ errorMessage . Contains ( string . Format ( "provider: {0}, error" , protocol ) ) ,
102+ string . Format ( "Expected protocol {0} in the error message, but received: {1}" , protocol , errorMessage ) ) ;
103+ }
104+ }
119105
120106 private static string Connect ( string connString )
121107 {
0 commit comments