22// The .NET Foundation licenses this file to you under the MIT license.
33// See the LICENSE file in the project root for more information.
44
5- using System ;
5+ using Microsoft . Data . SqlClient . Tests . Common ;
66using Xunit ;
77
88namespace Microsoft . Data . SqlClient . UnitTests ;
@@ -18,6 +18,37 @@ public class LocalAppContextSwitchesTest
1818 [ Fact ]
1919 public void TestDefaultAppContextSwitchValues ( )
2020 {
21+ // LocalAppContextSwitches caches each switch value on first access for
22+ // the lifetime of the process. Other tests running in parallel may
23+ // already have triggered caching, or may use LocalAppContextSwitchesHelper
24+ // to mutate the cached fields via reflection. To make this test
25+ // deterministic, acquire the helper (which serializes against every
26+ // other helper user via a process-wide semaphore) and reset each
27+ // cached field to None so the properties re-read from AppContext.
28+ using LocalAppContextSwitchesHelper switchesHelper = new ( ) ;
29+
30+ switchesHelper . EnableMultiSubnetFailoverByDefault = null ;
31+ switchesHelper . IgnoreServerProvidedFailoverPartner = null ;
32+ switchesHelper . UseLegacyFailoverAlternationOnLoginSqlErrors = null ;
33+ switchesHelper . LegacyRowVersionNullBehavior = null ;
34+ switchesHelper . LegacyVarTimeZeroScaleBehaviour = null ;
35+ switchesHelper . MakeReadAsyncBlocking = null ;
36+ switchesHelper . SuppressInsecureTlsWarning = null ;
37+ switchesHelper . TruncateScaledDecimal = null ;
38+ switchesHelper . UseCompatibilityAsyncBehaviour = null ;
39+ switchesHelper . UseCompatibilityProcessSni = null ;
40+ switchesHelper . UseConnectionPoolV2 = null ;
41+ switchesHelper . UseMinimumLoginTimeout = null ;
42+ #if NET
43+ switchesHelper . GlobalizationInvariantMode = null ;
44+ #endif
45+ #if NET && _WINDOWS
46+ switchesHelper . UseManagedNetworking = null ;
47+ #endif
48+ #if NETFRAMEWORK
49+ switchesHelper . DisableTnirByDefault = null ;
50+ #endif
51+
2152 Assert . False ( LocalAppContextSwitches . LegacyRowVersionNullBehavior ) ;
2253 Assert . False ( LocalAppContextSwitches . SuppressInsecureTlsWarning ) ;
2354 Assert . False ( LocalAppContextSwitches . MakeReadAsyncBlocking ) ;
0 commit comments