@@ -23,6 +23,15 @@ public static void SqlLocalDbConnectionTest()
2323            ConnectionTest ( s_localDbConnectionString ) ; 
2424        } 
2525
26+         [ SkipOnTargetFramework ( TargetFrameworkMonikers . Uap ) ]  // No Registry support on UAP 
27+         [ ConditionalFact ( nameof ( IsLocalDBEnvironmentSet ) ) ] 
28+         public  static   void  LocalDBEncryptionNotSupportedTest ( ) 
29+         { 
30+             // Encryption is not supported by SQL Local DB. 
31+             // But connection should succeed as encryption is disabled by driver. 
32+             ConnectionWithEncryptionTest ( s_localDbConnectionString ) ; 
33+         } 
34+ 
2635        [ SkipOnTargetFramework ( TargetFrameworkMonikers . Uap ) ]  // No Registry support on UAP 
2736        [ ConditionalFact ( nameof ( IsLocalDBEnvironmentSet ) ) ] 
2837        public  static   void  LocalDBMarsTest ( ) 
@@ -40,6 +49,18 @@ public static void InvalidLocalDBTest()
4049        #endregion
4150
4251        #region SharedLocalDb tests
52+         [ SkipOnTargetFramework ( TargetFrameworkMonikers . Uap ) ]  // No Registry support on UAP 
53+         [ ConditionalFact ( nameof ( IsLocalDbSharedInstanceSet ) ) ] 
54+         public  static   void  SharedLocalDbEncryptionTest ( ) 
55+         { 
56+             foreach  ( string  connectionString  in  s_sharedLocalDbInstances ) 
57+             { 
58+                 // Encryption is not supported by SQL Local DB. 
59+                 // But connection should succeed as encryption is disabled by driver. 
60+                 ConnectionWithEncryptionTest ( connectionString ) ; 
61+             } 
62+         } 
63+ 
4364        [ SkipOnTargetFramework ( TargetFrameworkMonikers . Uap ) ]  // No Registry support on UAP 
4465        [ ConditionalFact ( nameof ( IsLocalDbSharedInstanceSet ) ) ] 
4566        public  static   void  SharedLocalDbMarsTest ( ) 
@@ -67,18 +88,28 @@ private static void ConnectionWithMarsTest(string connectionString)
6788            { 
6889                IntegratedSecurity  =  true , 
6990                MultipleActiveResultSets  =  true , 
91+                 ConnectTimeout  =  2 
92+             } ; 
93+             OpenConnection ( builder . ConnectionString ) ; 
94+         } 
95+ 
96+         private  static   void  ConnectionWithEncryptionTest ( string  connectionString ) 
97+         { 
98+             SqlConnectionStringBuilder  builder  =  new ( connectionString ) 
99+             { 
100+                 IntegratedSecurity  =  true , 
70101                ConnectTimeout  =  2 , 
71-                 Encrypt  =  false 
102+                 Encrypt  =  true 
72103            } ; 
73104            OpenConnection ( builder . ConnectionString ) ; 
74105        } 
106+ 
75107        private  static   void  ConnectionTest ( string  connectionString ) 
76108        { 
77109            SqlConnectionStringBuilder  builder  =  new ( connectionString ) 
78110            { 
79111                IntegratedSecurity  =  true , 
80-                 ConnectTimeout  =  2 , 
81-                 Encrypt  =  false 
112+                 ConnectTimeout  =  2 
82113            } ; 
83114            OpenConnection ( builder . ConnectionString ) ; 
84115        } 
@@ -87,6 +118,7 @@ private static void OpenConnection(string connString)
87118        { 
88119            using  SqlConnection  connection  =  new ( connString ) ; 
89120            connection . Open ( ) ; 
121+             Assert . Equal ( System . Data . ConnectionState . Open ,  connection . State ) ; 
90122            using  SqlCommand  command  =  new  SqlCommand ( "SELECT @@SERVERNAME" ,  connection ) ; 
91123            var  result  =  command . ExecuteScalar ( ) ; 
92124            Assert . NotNull ( result ) ; 
0 commit comments