From da880132169bec5f5cbe4954aae1b939a1a09f4f Mon Sep 17 00:00:00 2001 From: David Engel Date: Mon, 12 Jun 2023 11:42:41 -0700 Subject: [PATCH] Fix | SqlDataSourceEnumeratorTest correct ConditionalFact (#2058) Skip test if SQLBrowser is missing or not running. --- .../SqlDataSourceEnumeratorTest.cs | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/Microsoft.Data.SqlClient/tests/ManualTests/SQL/SqlDSEnumeratorTest/SqlDataSourceEnumeratorTest.cs b/src/Microsoft.Data.SqlClient/tests/ManualTests/SQL/SqlDSEnumeratorTest/SqlDataSourceEnumeratorTest.cs index 2726f5441d..f78e4c1254 100644 --- a/src/Microsoft.Data.SqlClient/tests/ManualTests/SQL/SqlDSEnumeratorTest/SqlDataSourceEnumeratorTest.cs +++ b/src/Microsoft.Data.SqlClient/tests/ManualTests/SQL/SqlDSEnumeratorTest/SqlDataSourceEnumeratorTest.cs @@ -15,7 +15,17 @@ namespace Microsoft.Data.SqlClient.ManualTesting.Tests #endif public class SqlDataSourceEnumeratorTest { - [ConditionalFact(typeof(DataTestUtility), nameof(DataTestUtility.IsNotUsingManagedSNIOnWindows))] + private static bool IsEnvironmentAvailable() + { + ServiceController[] services = ServiceController.GetServices(Environment.MachineName); + ServiceController service = services.FirstOrDefault(s => s.ServiceName == "SQLBrowser"); + + return DataTestUtility.IsNotUsingManagedSNIOnWindows() && + service != null && + service.Status == ServiceControllerStatus.Running; + } + + [ConditionalFact(nameof(IsEnvironmentAvailable))] [PlatformSpecific(TestPlatforms.Windows)] public void SqlDataSourceEnumerator_NativeSNI() {