Skip to content

Commit

Permalink
Fix | Improved DSEnumerator's test and fixed string format (#1541)
Browse files Browse the repository at this point in the history
  • Loading branch information
DavoudEshtehari authored Mar 11, 2022
1 parent 5cebfbe commit 865ac03
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ internal static DataTable GetDataSources()
finally
{
handle = SNINativeMethodWrapper.SNIServerEnumOpen();
SqlClientEventSource.Log.TryTraceEvent("<sc.{0}.{1}|INFO> {3} returned handle = {4}.",
SqlClientEventSource.Log.TryTraceEvent("<sc.{0}.{1}|INFO> {2} returned handle = {3}.",
nameof(SqlDataSourceEnumeratorNativeHelper),
nameof(GetDataSources),
nameof(SNINativeMethodWrapper.SNIServerEnumOpen), handle);
Expand Down Expand Up @@ -80,7 +80,7 @@ internal static DataTable GetDataSources()
if (handle != ADP.s_ptrZero)
{
SNINativeMethodWrapper.SNIServerEnumClose(handle);
SqlClientEventSource.Log.TryTraceEvent("<sc.{0}.{1}|INFO> {3} called.",
SqlClientEventSource.Log.TryTraceEvent("<sc.{0}.{1}|INFO> {2} called.",
nameof(SqlDataSourceEnumeratorNativeHelper),
nameof(GetDataSources),
nameof(SNINativeMethodWrapper.SNIServerEnumClose));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
// See the LICENSE file in the project root for more information.

using System;
using System.Linq;
using System.ServiceProcess;
using Microsoft.Data.Sql;
using Xunit;
Expand Down Expand Up @@ -36,9 +37,12 @@ private SqlDataSourceEnumerator GetDSEnumerator()
{
// SQL Server Browser runs as a Windows service.
// TODO: This assessment can be done on CI.
ServiceController sc = new("SQLBrowser");
Assert.Equal(ServiceControllerStatus.Running, sc.Status);

ServiceController[] services = ServiceController.GetServices(Environment.MachineName);
ServiceController service = services.FirstOrDefault(s => s.ServiceName == "SQLBrowser");
if (service != null)
{
Assert.Equal(ServiceControllerStatus.Running, service.Status);
}
return SqlDataSourceEnumerator.Instance;
}
}
Expand Down

0 comments on commit 865ac03

Please sign in to comment.