1010using System . Reflection ;
1111using System . Runtime . InteropServices ;
1212using System . Security ;
13- using System . Threading ;
14- using System . Threading . Tasks ;
1513using Microsoft . SqlServer . TDS . Servers ;
1614using Xunit ;
1715
@@ -57,26 +55,6 @@ public async Task PreLoginEncryptionExcludedTest()
5755 Assert . Contains ( "The instance of SQL Server you attempted to connect to does not support encryption." , ex . Message , StringComparison . OrdinalIgnoreCase ) ;
5856 }
5957
60- [ ConditionalTheory ( typeof ( TestUtility ) , nameof ( TestUtility . IsNotArmProcess ) ) ]
61- [ InlineData ( 40613 ) ]
62- [ InlineData ( 42108 ) ]
63- [ InlineData ( 42109 ) ]
64- [ PlatformSpecific ( TestPlatforms . Windows ) ]
65- public async Task TransientFaultTestAsync ( uint errorCode )
66- {
67- using TransientFaultTDSServer server = TransientFaultTDSServer . StartTestServer ( true , true , errorCode ) ;
68- SqlConnectionStringBuilder builder = new ( )
69- {
70- DataSource = "localhost," + server . Port ,
71- IntegratedSecurity = true ,
72- Encrypt = SqlConnectionEncryptOption . Optional
73- } ;
74-
75- using SqlConnection connection = new ( builder . ConnectionString ) ;
76- await connection . OpenAsync ( ) ;
77- Assert . Equal ( ConnectionState . Open , connection . State ) ;
78- }
79-
8058 [ ConditionalTheory ( typeof ( TestUtility ) , nameof ( TestUtility . IsNotArmProcess ) ) ]
8159 [ InlineData ( 40613 ) ]
8260 [ InlineData ( 42108 ) ]
@@ -100,54 +78,14 @@ public void TransientFaultTest(uint errorCode)
10078 }
10179 catch ( Exception e )
10280 {
103- Assert . Fail ( e . Message ) ;
81+ if ( null != connection )
82+ {
83+ Assert . Equal ( ConnectionState . Closed , connection . State ) ;
84+ }
85+ Assert . False ( true , e . Message ) ;
10486 }
10587 }
10688
107- [ ConditionalTheory ( typeof ( TestUtility ) , nameof ( TestUtility . IsNotArmProcess ) ) ]
108- [ InlineData ( 40613 ) ]
109- [ InlineData ( 42108 ) ]
110- [ InlineData ( 42109 ) ]
111- [ PlatformSpecific ( TestPlatforms . Windows ) ]
112- public void TransientFaultDisabledTestAsync ( uint errorCode )
113- {
114- using TransientFaultTDSServer server = TransientFaultTDSServer . StartTestServer ( true , true , errorCode ) ;
115- SqlConnectionStringBuilder builder = new ( )
116- {
117- DataSource = "localhost," + server . Port ,
118- IntegratedSecurity = true ,
119- ConnectRetryCount = 0 ,
120- Encrypt = SqlConnectionEncryptOption . Optional
121- } ;
122-
123- using SqlConnection connection = new ( builder . ConnectionString ) ;
124- Task < SqlException > e = Assert . ThrowsAsync < SqlException > ( async ( ) => await connection . OpenAsync ( ) ) ;
125- Assert . Equal ( 20 , e . Result . Class ) ;
126- Assert . Equal ( ConnectionState . Closed , connection . State ) ;
127- }
128-
129- [ ConditionalTheory ( typeof ( TestUtility ) , nameof ( TestUtility . IsNotArmProcess ) ) ]
130- [ InlineData ( 40613 ) ]
131- [ InlineData ( 42108 ) ]
132- [ InlineData ( 42109 ) ]
133- [ PlatformSpecific ( TestPlatforms . Windows ) ]
134- public void TransientFaultDisabledTest ( uint errorCode )
135- {
136- using TransientFaultTDSServer server = TransientFaultTDSServer . StartTestServer ( true , true , errorCode ) ;
137- SqlConnectionStringBuilder builder = new ( )
138- {
139- DataSource = "localhost," + server . Port ,
140- IntegratedSecurity = true ,
141- ConnectRetryCount = 0 ,
142- Encrypt = SqlConnectionEncryptOption . Optional
143- } ;
144-
145- using SqlConnection connection = new ( builder . ConnectionString ) ;
146- SqlException e = Assert . Throws < SqlException > ( ( ) => connection . Open ( ) ) ;
147- Assert . Equal ( 20 , e . Class ) ;
148- Assert . Equal ( ConnectionState . Closed , connection . State ) ;
149- }
150-
15189 [ Fact ]
15290 public void SqlConnectionDbProviderFactoryTest ( )
15391 {
0 commit comments