forked from dotnet/SqlClient
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
SqlDataSourceEnumerator test update and different file for unix, windows
- Loading branch information
1 parent
81e26f6
commit 7ff8220
Showing
12 changed files
with
112 additions
and
70 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 15 additions & 0 deletions
15
src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/Sql/SqlDataSourceEnumerator.Unix.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
// See the LICENSE file in the project root for more information. | ||
using System.Data; | ||
using System.Data.Common; | ||
using Microsoft.Data.SqlClient.Server; | ||
|
||
namespace Microsoft.Data.Sql | ||
{ | ||
/// <include file='../../../../doc/snippets/Microsoft.Data.Sql/SqlDataSourceEnumerator.xml' path='docs/members[@name="SqlDataSourceEnumerator"]/SqlDataSourceEnumerator/*' /> | ||
public sealed partial class SqlDataSourceEnumerator : DbDataSourceEnumerator | ||
{ | ||
private partial DataTable GetDataSourcesInternal() => SqlDataSourceEnumeratorManagedHelper.GetDataSources(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 22 additions & 0 deletions
22
src/Microsoft.Data.SqlClient/src/Microsoft/Data/Sql/SqlDataSourceEnumerator.Windows.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
// See the LICENSE file in the project root for more information. | ||
using System.Data; | ||
using System.Data.Common; | ||
using Microsoft.Data.SqlClient.Server; | ||
|
||
namespace Microsoft.Data.Sql | ||
{ | ||
/// <include file='../../../../doc/snippets/Microsoft.Data.Sql/SqlDataSourceEnumerator.xml' path='docs/members[@name="SqlDataSourceEnumerator"]/SqlDataSourceEnumerator/*' /> | ||
public sealed partial class SqlDataSourceEnumerator : DbDataSourceEnumerator | ||
{ | ||
private partial DataTable GetDataSourcesInternal() | ||
{ | ||
#if NETFRAMEWORK | ||
return SqlDataSourceEnumeratorNativeHelper.GetDataSources(); | ||
#else | ||
return SqlClient.TdsParserStateObjectFactory.UseManagedSNI ? SqlDataSourceEnumeratorManagedHelper.GetDataSources() : SqlDataSourceEnumeratorNativeHelper.GetDataSources(); | ||
#endif | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 0 additions & 33 deletions
33
src/Microsoft.Data.SqlClient/tests/FunctionalTests/SqlDataSourceEnumeratorTest.cs
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 40 additions & 0 deletions
40
...t.Data.SqlClient/tests/ManualTests/SQL/SqlDSEnumeratorTest/SqlDataSourceEnumeratorTest.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
// See the LICENSE file in the project root for more information. | ||
|
||
using System; | ||
using System.ServiceProcess; | ||
using Microsoft.Data.Sql; | ||
using Xunit; | ||
|
||
namespace Microsoft.Data.SqlClient.ManualTesting.Tests | ||
{ | ||
public class SqlDataSourceEnumeratorTest | ||
{ | ||
[ConditionalFact(typeof(DataTestUtility), nameof(DataTestUtility.IsNotUsingManagedSNIOnWindows))] | ||
[PlatformSpecific(TestPlatforms.Windows)] | ||
public void SqlDataSourceEnumerator_NativeSNI() | ||
{ | ||
// The returned rows depends on the running services which could be zero or more. | ||
int count = GetDSEnumerator().GetDataSources().Rows.Count; | ||
Assert.InRange(count, 0, 65536); | ||
} | ||
|
||
[SkipOnTargetFramework(TargetFrameworkMonikers.NetFramework)] | ||
[ConditionalFact(typeof(DataTestUtility), nameof(DataTestUtility.IsUsingManagedSNI))] | ||
[PlatformSpecific(TestPlatforms.Windows)] | ||
public void SqlDataSourceEnumerator_ManagedSNI() | ||
{ | ||
// after adding the managed SNI support, this test should have the same result as SqlDataSourceEnumerator_NativeSNI | ||
Assert.Throws<NotImplementedException>(() => GetDSEnumerator().GetDataSources()); | ||
} | ||
|
||
private SqlDataSourceEnumerator GetDSEnumerator() | ||
{ | ||
ServiceController sc = new("SQLBrowser"); | ||
Assert.Equal(ServiceControllerStatus.Running, sc.Status); | ||
|
||
return SqlDataSourceEnumerator.Instance; | ||
} | ||
} | ||
} |