Skip to content

Commit 2b31810

Browse files
authored
Fix | SqlDataSourceEnumeratorTest correct ConditionalFact (#2058)
Skip test if SQLBrowser is missing or not running.
1 parent 244a340 commit 2b31810

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

src/Microsoft.Data.SqlClient/tests/ManualTests/SQL/SqlDSEnumeratorTest/SqlDataSourceEnumeratorTest.cs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,17 @@ namespace Microsoft.Data.SqlClient.ManualTesting.Tests
1515
#endif
1616
public class SqlDataSourceEnumeratorTest
1717
{
18-
[ConditionalFact(typeof(DataTestUtility), nameof(DataTestUtility.IsNotUsingManagedSNIOnWindows))]
18+
private static bool IsEnvironmentAvailable()
19+
{
20+
ServiceController[] services = ServiceController.GetServices(Environment.MachineName);
21+
ServiceController service = services.FirstOrDefault(s => s.ServiceName == "SQLBrowser");
22+
23+
return DataTestUtility.IsNotUsingManagedSNIOnWindows() &&
24+
service != null &&
25+
service.Status == ServiceControllerStatus.Running;
26+
}
27+
28+
[ConditionalFact(nameof(IsEnvironmentAvailable))]
1929
[PlatformSpecific(TestPlatforms.Windows)]
2030
public void SqlDataSourceEnumerator_NativeSNI()
2131
{

0 commit comments

Comments
 (0)