Skip to content

Commit b5ac613

Browse files
committed
Make the default-switch test tolerate a configured managed SNI switch
TestDefaultAppContextSwitchValues asserted that UseManagedNetworking is false on Windows, which fails in the managed SNI test leg now that the switch is enabled process-wide through runtimeconfig.json. Compare the property against AppContext instead, so the assertion still verifies that the switch is honoured and remains unchanged when the switch is not configured.
1 parent 2292593 commit b5ac613

2 files changed

Lines changed: 7 additions & 2 deletions

File tree

eng/pipelines/ci/kerberos/linux-setup-step.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,4 +107,4 @@ steps:
107107
Invoke-Sqlcmd -Query "SELECT @@VERSION, @@SERVERNAME" -ConnectionString $env:REMOTE_TCP_CONN_STRING
108108
displayName: Verify SQL connectivity
109109
env:
110-
REMOTE_TCP_CONN_STRING: $(REMOTE_TCP_CONN_STRING)
110+
REMOTE_TCP_CONN_STRING: $(REMOTE_TCP_CONN_STRING)

src/Microsoft.Data.SqlClient/tests/UnitTests/Microsoft/Data/SqlClient/LocalAppContextSwitchesTest.cs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,12 @@ public void TestDefaultAppContextSwitchValues()
7373
Assert.False(switchesHelper.GlobalizationInvariantMode);
7474
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
7575
{
76-
Assert.False(switchesHelper.UseManagedNetworking);
76+
// The managed SNI test leg enables this switch process-wide via runtimeconfig.json,
77+
// so compare against AppContext rather than assuming the switch is unset.
78+
System.AppContext.TryGetSwitch(
79+
"Switch.Microsoft.Data.SqlClient.UseManagedNetworkingOnWindows",
80+
out bool useManagedNetworking);
81+
Assert.Equal<bool?>(useManagedNetworking, switchesHelper.UseManagedNetworking);
7782
}
7883
else
7984
{

0 commit comments

Comments
 (0)