diff --git a/build.proj b/build.proj index df4d4c12a6..95b9ca5fdc 100644 --- a/build.proj +++ b/build.proj @@ -78,19 +78,8 @@ - - - - - - - - - - - - - + + @@ -99,9 +88,12 @@ - - - + + + + + + @@ -112,16 +104,16 @@ - - + + - - + + @@ -169,24 +161,6 @@ - - - - - - - - - - - - - - - - - - @@ -296,13 +270,9 @@ $(DotnetPath)dotnet test "@(ManualTestsProj)" - --no-build - -v n + -f $(TF) -p:Configuration=$(Configuration) - -p:Target$(TFGroup)Version=$(TF) -p:ReferenceType=$(ReferenceType) - -p:TestSet=$(TestSet) - -p:TestTargetOS=Windows$(TargetGroup) $(CollectStatement) --results-directory $(ResultsDirectory) --filter "$(FilterStatement)" @@ -311,7 +281,18 @@ --blame-hang-dump-type full --blame-hang-timeout 10m - $(TestCommand.Replace($([System.Environment]::NewLine), " ")) + + + + $(TestCommand) + -p:TestSet=$(TestSet) + + + + $([System.Text.RegularExpressions.Regex]::Replace($(TestCommand), "\s+", " ")) @@ -322,13 +303,10 @@ $(DotnetPath)dotnet test "@(ManualTestsProj)" - --no-build - -v n + -f $(TF) -p:Configuration=$(Configuration) - -p:TargetNetCoreVersion=$(TF) -p:ReferenceType=$(ReferenceType) -p:TestSet=$(TestSet) - -p:TestTargetOS=Unixnetcoreapp $(CollectStatement) --results-directory $(ResultsDirectory) --filter "$(FilterStatement)" @@ -337,7 +315,8 @@ --blame-hang-dump-type full --blame-hang-timeout 10m - $(TestCommand.Replace($([System.Environment]::NewLine), " ")) + + $([System.Text.RegularExpressions.Regex]::Replace($(TestCommand), "\s+", " ")) @@ -384,31 +363,16 @@ - - - - - - - - + + - - - - - - - - + + - - - - - + + diff --git a/src/Microsoft.Data.SqlClient.sln b/src/Microsoft.Data.SqlClient.sln index d07bffd4c4..f58786f4d5 100644 --- a/src/Microsoft.Data.SqlClient.sln +++ b/src/Microsoft.Data.SqlClient.sln @@ -26,7 +26,7 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Address", "Microsoft.Data.S {407890AC-9876-4FEF-A6F1-F36A876BAADE} = {407890AC-9876-4FEF-A6F1-F36A876BAADE} EndProjectSection EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Data.SqlClient.ManualTesting.Tests", "Microsoft.Data.SqlClient\tests\ManualTests\Microsoft.Data.SqlClient.ManualTesting.Tests.csproj", "{45DB5F86-7AE3-45C6-870D-F9357B66BDB5}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Data.SqlClient.ManualTests", "Microsoft.Data.SqlClient\tests\ManualTests\Microsoft.Data.SqlClient.ManualTests.csproj", "{45DB5F86-7AE3-45C6-870D-F9357B66BDB5}" ProjectSection(ProjectDependencies) = postProject {37431336-5307-4184-9356-C4B7E47DC714} = {37431336-5307-4184-9356-C4B7E47DC714} EndProjectSection diff --git a/src/Microsoft.Data.SqlClient/add-ons/AzureKeyVaultProvider/Microsoft.Data.SqlClient.AlwaysEncrypted.AzureKeyVaultProvider.csproj b/src/Microsoft.Data.SqlClient/add-ons/AzureKeyVaultProvider/Microsoft.Data.SqlClient.AlwaysEncrypted.AzureKeyVaultProvider.csproj index 31f6b3fcb1..646de8a432 100644 --- a/src/Microsoft.Data.SqlClient/add-ons/AzureKeyVaultProvider/Microsoft.Data.SqlClient.AlwaysEncrypted.AzureKeyVaultProvider.csproj +++ b/src/Microsoft.Data.SqlClient/add-ons/AzureKeyVaultProvider/Microsoft.Data.SqlClient.AlwaysEncrypted.AzureKeyVaultProvider.csproj @@ -1,40 +1,45 @@  - Microsoft.Data.SqlClient.AlwaysEncrypted.AzureKeyVaultProvider Microsoft.Data.SqlClient.AlwaysEncrypted.AzureKeyVaultProvider - AzureKeyVaultProvider - {9073ABEF-92E0-4702-BB23-2C99CEF9BDD7} - netcoreapp - netfx - Debug;Release; - AnyCPU;x86;x64 - $(ObjFolder)$(Configuration).$(Platform)\$(AddOnName) - $(BinFolder)$(Configuration).$(Platform)\$(AddOnName) - $(BinFolder)$(Configuration).$(Platform)\$(AssemblyName).xml - - false + Microsoft.Data.SqlClient.AlwaysEncrypted.AzureKeyVaultProvider MIT true - true - true - - - true - $(SigningKeyPath) + + + + + $(BinFolder)$(Configuration).$(Platform)\AzureKeyVaultProvider + $(ObjFolder)$(Configuration).$(Platform)\AzureKeyVaultProvider + $(BinFolder)$(Configuration).$(Platform)\$(AssemblyName).xml + + + + true + true + + + $(SigningKeyPath) + + true + $(SigningKeyPath) + + + + - - - - - - + + + + diff --git a/src/Microsoft.Data.SqlClient/netcore/src/Microsoft.Data.SqlClient.csproj b/src/Microsoft.Data.SqlClient/netcore/src/Microsoft.Data.SqlClient.csproj index bbbf05277b..db746e5d95 100644 --- a/src/Microsoft.Data.SqlClient/netcore/src/Microsoft.Data.SqlClient.csproj +++ b/src/Microsoft.Data.SqlClient/netcore/src/Microsoft.Data.SqlClient.csproj @@ -1042,9 +1042,10 @@ Resources\ILLink.Substitutions.xml + Resources\Microsoft.Data.SqlCLient.SqlMetaData.xml - Microsoft.Data.SqlClient.SqlMetaData.xml + Microsoft.Data.SqlClient.SqlMetaData.xml diff --git a/src/Microsoft.Data.SqlClient/src/Microsoft.Data.SqlClient.csproj b/src/Microsoft.Data.SqlClient/src/Microsoft.Data.SqlClient.csproj index 2e38c79532..af0e42d814 100644 --- a/src/Microsoft.Data.SqlClient/src/Microsoft.Data.SqlClient.csproj +++ b/src/Microsoft.Data.SqlClient/src/Microsoft.Data.SqlClient.csproj @@ -74,9 +74,15 @@ - + + + Resources\Microsoft.Data.SqlCLient.SqlMetaData.xml + Microsoft.Data.SqlClient.SqlMetaData.xml + + Microsoft.Data.SqlClient.Resources.Strings.resources diff --git a/src/Microsoft.Data.SqlClient/tests/FunctionalTests/Microsoft.Data.SqlClient.FunctionalTests.csproj b/src/Microsoft.Data.SqlClient/tests/FunctionalTests/Microsoft.Data.SqlClient.FunctionalTests.csproj index 3cdd360113..2d195a13f9 100644 --- a/src/Microsoft.Data.SqlClient/tests/FunctionalTests/Microsoft.Data.SqlClient.FunctionalTests.csproj +++ b/src/Microsoft.Data.SqlClient/tests/FunctionalTests/Microsoft.Data.SqlClient.FunctionalTests.csproj @@ -7,8 +7,14 @@ - + + + + + + + @@ -16,16 +22,16 @@ - - + + Always - + PreserveNewest xunit.runner.json - + diff --git a/src/Microsoft.Data.SqlClient/tests/ManualTests/AlwaysEncrypted/CspProviderExt.cs b/src/Microsoft.Data.SqlClient/tests/ManualTests/AlwaysEncrypted/CspProviderExt.windows.cs similarity index 96% rename from src/Microsoft.Data.SqlClient/tests/ManualTests/AlwaysEncrypted/CspProviderExt.cs rename to src/Microsoft.Data.SqlClient/tests/ManualTests/AlwaysEncrypted/CspProviderExt.windows.cs index 54a4b0c175..fb81905936 100644 --- a/src/Microsoft.Data.SqlClient/tests/ManualTests/AlwaysEncrypted/CspProviderExt.cs +++ b/src/Microsoft.Data.SqlClient/tests/ManualTests/AlwaysEncrypted/CspProviderExt.windows.cs @@ -2,6 +2,9 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. +// TODO: These tests are marked as Windows only for now but should be run for all platforms once the Master Key is accessible to this app from Azure Key Vault. +#if _WINDOWS + using System.Collections.Generic; using System.IO; using System.Linq; @@ -19,12 +22,7 @@ namespace Microsoft.Data.SqlClient.ManualTesting.Tests.AlwaysEncrypted { /// /// Always Encrypted public CspProvider Manual tests. - /// TODO: These tests are marked as Windows only for now but should be run for all platforms once the Master Key is accessible to this app from Azure Key Vault. /// -#if !NETFRAMEWORK - [SupportedOSPlatform("windows")] -#endif - [PlatformSpecific(TestPlatforms.Windows)] public class CspProviderExt { // [Fact(Skip="Run this in non-parallel mode")] or [ConditionalFact()] @@ -142,3 +140,5 @@ private void ValidateResultSet(SqlDataReader sqlDataReader) } } } + +#endif diff --git a/src/Microsoft.Data.SqlClient/tests/ManualTests/AlwaysEncrypted/DateOnlyReadTests.cs b/src/Microsoft.Data.SqlClient/tests/ManualTests/AlwaysEncrypted/DateOnlyReadTests.netcore.cs similarity index 99% rename from src/Microsoft.Data.SqlClient/tests/ManualTests/AlwaysEncrypted/DateOnlyReadTests.cs rename to src/Microsoft.Data.SqlClient/tests/ManualTests/AlwaysEncrypted/DateOnlyReadTests.netcore.cs index 2cd1e18019..679fb4bf07 100644 --- a/src/Microsoft.Data.SqlClient/tests/ManualTests/AlwaysEncrypted/DateOnlyReadTests.cs +++ b/src/Microsoft.Data.SqlClient/tests/ManualTests/AlwaysEncrypted/DateOnlyReadTests.netcore.cs @@ -2,6 +2,8 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. +#if NET + using System; using System.Collections; using System.Collections.Generic; @@ -91,3 +93,5 @@ public IEnumerator GetEnumerator() IEnumerator IEnumerable.GetEnumerator() => GetEnumerator(); } } + +#endif diff --git a/src/Microsoft.Data.SqlClient/tests/ManualTests/AlwaysEncrypted/TestFixtures/Setup/CspProviderColumnMasterKey.cs b/src/Microsoft.Data.SqlClient/tests/ManualTests/AlwaysEncrypted/TestFixtures/Setup/CspProviderColumnMasterKey.windows.cs similarity index 98% rename from src/Microsoft.Data.SqlClient/tests/ManualTests/AlwaysEncrypted/TestFixtures/Setup/CspProviderColumnMasterKey.cs rename to src/Microsoft.Data.SqlClient/tests/ManualTests/AlwaysEncrypted/TestFixtures/Setup/CspProviderColumnMasterKey.windows.cs index 1774140057..ac6662831f 100644 --- a/src/Microsoft.Data.SqlClient/tests/ManualTests/AlwaysEncrypted/TestFixtures/Setup/CspProviderColumnMasterKey.cs +++ b/src/Microsoft.Data.SqlClient/tests/ManualTests/AlwaysEncrypted/TestFixtures/Setup/CspProviderColumnMasterKey.windows.cs @@ -2,7 +2,8 @@ // 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; +#if _WINDOWS + using System.Security.Cryptography.X509Certificates; namespace Microsoft.Data.SqlClient.ManualTesting.Tests.AlwaysEncrypted.Setup @@ -29,3 +30,5 @@ public CspProviderColumnMasterKey(string name, string providerName, string cspKe } } + +#endif diff --git a/src/Microsoft.Data.SqlClient/tests/ManualTests/AlwaysEncrypted/TestFixtures/SQLSetupStrategyCspProvider.cs b/src/Microsoft.Data.SqlClient/tests/ManualTests/AlwaysEncrypted/TestFixtures/SqlSetupStrategyCspProvider.windows.cs similarity index 99% rename from src/Microsoft.Data.SqlClient/tests/ManualTests/AlwaysEncrypted/TestFixtures/SQLSetupStrategyCspProvider.cs rename to src/Microsoft.Data.SqlClient/tests/ManualTests/AlwaysEncrypted/TestFixtures/SqlSetupStrategyCspProvider.windows.cs index 08cdfe48ec..88863fe750 100644 --- a/src/Microsoft.Data.SqlClient/tests/ManualTests/AlwaysEncrypted/TestFixtures/SQLSetupStrategyCspProvider.cs +++ b/src/Microsoft.Data.SqlClient/tests/ManualTests/AlwaysEncrypted/TestFixtures/SqlSetupStrategyCspProvider.windows.cs @@ -2,6 +2,8 @@ // 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; +#if _WINDOWS + using System; using System.Collections.Generic; using System.Security.Cryptography; @@ -75,3 +77,5 @@ protected override void Dispose(bool disposing) } } } + +#endif diff --git a/src/Microsoft.Data.SqlClient/tests/ManualTests/DDBasics/DDDataTypesTest/DDDataTypesTest.cs b/src/Microsoft.Data.SqlClient/tests/ManualTests/DDBasics/DDDataTypesTest/DDDataTypesTest.cs index 0d1e0e7e68..eda1a2c788 100644 --- a/src/Microsoft.Data.SqlClient/tests/ManualTests/DDBasics/DDDataTypesTest/DDDataTypesTest.cs +++ b/src/Microsoft.Data.SqlClient/tests/ManualTests/DDBasics/DDDataTypesTest/DDDataTypesTest.cs @@ -39,7 +39,7 @@ public static void XmlTest() SqlCommand cmd2 = new SqlCommand(insertParamStr, conn); cmd2.Parameters.Add("@x", SqlDbType.Xml); - XmlReader xr = XmlReader.Create("data.xml"); + XmlReader xr = XmlReader.Create("DDDataTypesTest_Data.xml"); cmd2.Parameters[0].Value = new SqlXml(xr); cmd2.ExecuteNonQuery(); diff --git a/src/Microsoft.Data.SqlClient/tests/ManualTests/DDBasics/DDDataTypesTest/data.xml b/src/Microsoft.Data.SqlClient/tests/ManualTests/DDDataTypesTest_Data.xml similarity index 100% rename from src/Microsoft.Data.SqlClient/tests/ManualTests/DDBasics/DDDataTypesTest/data.xml rename to src/Microsoft.Data.SqlClient/tests/ManualTests/DDDataTypesTest_Data.xml diff --git a/src/Microsoft.Data.SqlClient/tests/ManualTests/Microsoft.Data.SqlClient.ManualTesting.Tests.csproj b/src/Microsoft.Data.SqlClient/tests/ManualTests/Microsoft.Data.SqlClient.ManualTests.csproj similarity index 64% rename from src/Microsoft.Data.SqlClient/tests/ManualTests/Microsoft.Data.SqlClient.ManualTesting.Tests.csproj rename to src/Microsoft.Data.SqlClient/tests/ManualTests/Microsoft.Data.SqlClient.ManualTests.csproj index 3155b87f81..8bb45feb1d 100644 --- a/src/Microsoft.Data.SqlClient/tests/ManualTests/Microsoft.Data.SqlClient.ManualTesting.Tests.csproj +++ b/src/Microsoft.Data.SqlClient/tests/ManualTests/Microsoft.Data.SqlClient.ManualTests.csproj @@ -1,76 +1,98 @@  - {45DB5F86-7AE3-45C6-870D-F9357B66BDB5} + ManualTests - netfx - netcoreapp - false - Microsoft.Data.SqlClient.ManualTesting.Tests.ruleset - win - win-$(Platform) - $(ObjFolder)$(Configuration).$(Platform).$(AssemblyName) - $(BinFolder)$(Configuration).$(Platform).$(AssemblyName) + Microsoft.Data.SqlClient.ManualTests true + + + false - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + $(OS) + + + + + + + + $(TargetOs.ToLower()) + + + + $(DefineConstants);_UNIX + $(DefineConstants);_WINDOWS + + + + + + + + + + + + 123AE + $(TestSet.ToLower()) + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + + + + - + + + - + + + @@ -89,6 +111,7 @@ + @@ -96,22 +119,23 @@ - - + - + - - + + + + @@ -128,16 +152,25 @@ - + + + + + + + + + + @@ -145,33 +178,24 @@ - - - - - - - - - - - + - - - - + + + - - + + + + @@ -185,9 +209,20 @@ + + + + + + + + + + + - + @@ -196,9 +231,9 @@ - - + + @@ -206,169 +241,165 @@ - + - - - - - - - - - - - - - PreserveNewest - SqlParameterTest_DebugMode.bsl - - - PreserveNewest - SqlParameterTest_DebugMode_Azure.bsl - - - PreserveNewest - SqlParameterTest_ReleaseMode.bsl - - - PreserveNewest - SqlParameterTest_ReleaseMode_Azure.bsl - - - PreserveNewest - data.xml - - - - - - - - - + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - Common - - - Address - - - Circle - - - Shapes - - - Utf8String - - - - - - - - - + + + + + + + + + + - - - - - runtime; build; native; contentfiles; analyzers; buildtransitive - all - - - runtime; build; native; contentfiles; analyzers; buildtransitive - all - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - + + + - + + + + - - - - - runtime; build; native; contentfiles; analyzers; buildtransitive - all - - - PreserveNewest - %(Filename)%(Extension) - - - - - PreserveNewest - - - PreserveNewest - - - PreserveNewest - - - Always - - - PreserveNewest - xunit.runner.json - + + + + + + + + + + + + + + + diff --git a/src/Microsoft.Data.SqlClient/tests/ManualTests/SQL/AdapterTest/AdapterTest.cs b/src/Microsoft.Data.SqlClient/tests/ManualTests/SQL/AdapterTest/AdapterTest.cs index 552fbf3119..5b498b7318 100644 --- a/src/Microsoft.Data.SqlClient/tests/ManualTests/SQL/AdapterTest/AdapterTest.cs +++ b/src/Microsoft.Data.SqlClient/tests/ManualTests/SQL/AdapterTest/AdapterTest.cs @@ -1398,45 +1398,67 @@ public void TestReadOnlyColumnMetadata() } [ConditionalTheory(typeof(DataTestUtility), nameof(DataTestUtility.AreConnStringsSetup), nameof(DataTestUtility.IsNotAzureSynapse))] - [InlineData(nameof(SqlCommandBuilder.GetInsertCommand), null)] - [InlineData(nameof(SqlCommandBuilder.GetInsertCommand), true)] - [InlineData(nameof(SqlCommandBuilder.GetInsertCommand), false)] - [InlineData(nameof(SqlCommandBuilder.GetUpdateCommand), null)] - [InlineData(nameof(SqlCommandBuilder.GetUpdateCommand), true)] - [InlineData(nameof(SqlCommandBuilder.GetUpdateCommand), false)] - [InlineData(nameof(SqlCommandBuilder.GetDeleteCommand), null)] - [InlineData(nameof(SqlCommandBuilder.GetDeleteCommand), false)] - [InlineData(nameof(SqlCommandBuilder.GetDeleteCommand), true)] - public void VerifyGetCommand(string methodName, bool? useColumnsForParameterNames) + [InlineData(null)] + [InlineData(false)] + [InlineData(true)] + public void VerifyDeleteCommand(bool? useColumnsForParameterNames) { - using (SqlConnection connection = new SqlConnection(DataTestUtility.TCPConnectionString)) + if (useColumnsForParameterNames.HasValue) { - connection.Open(); - using (SqlDataAdapter dataAdapter = new SqlDataAdapter("SELECT * FROM dbo.Customers", connection)) - { - using (SqlCommandBuilder commandBuilder = new SqlCommandBuilder(dataAdapter)) - { - object[] parameters = null; - Type[] parameterTypes = null; - if (useColumnsForParameterNames != null) - { - parameters = new object[] { useColumnsForParameterNames }; - parameterTypes = new Type[] { typeof(bool) }; - } - else - { - parameters = new object[] { }; - parameterTypes = new Type[] { }; - } + VerifyGetCommand(commandBuilder => commandBuilder.GetDeleteCommand(useColumnsForParameterNames.Value)); + } + else + { + VerifyGetCommand(commandBuilder => commandBuilder.GetDeleteCommand()); + } + } - MethodInfo method = commandBuilder.GetType().GetMethod(methodName, parameterTypes); - using (SqlCommand cmd = (SqlCommand)method.Invoke(commandBuilder, parameters)) - { - Assert.NotNull(cmd); - } - } - } + [ConditionalTheory(typeof(DataTestUtility), nameof(DataTestUtility.AreConnStringsSetup), nameof(DataTestUtility.IsNotAzureSynapse))] + [InlineData(null)] + [InlineData(false)] + [InlineData(true)] + public void VerifyInsertCommand(bool? useColumnsForParameterNames) + { + if (useColumnsForParameterNames.HasValue) + { + VerifyGetCommand(commandBuilder => commandBuilder.GetInsertCommand(useColumnsForParameterNames.Value)); + } + else + { + VerifyGetCommand(commandBuilder => commandBuilder.GetInsertCommand()); + } + } + + [ConditionalTheory(typeof(DataTestUtility), nameof(DataTestUtility.AreConnStringsSetup), nameof(DataTestUtility.IsNotAzureSynapse))] + [InlineData(null)] + [InlineData(false)] + [InlineData(true)] + public void VerifyUpdateCommand(bool? useColumnsForParameterNames) + { + if (useColumnsForParameterNames.HasValue) + { + VerifyGetCommand(commandBuilder => commandBuilder.GetUpdateCommand(useColumnsForParameterNames.Value)); } + else + { + VerifyGetCommand(commandBuilder => commandBuilder.GetUpdateCommand()); + } + } + + private static void VerifyGetCommand(Func getFunc) + { + // Arrange + using SqlConnection connection = new SqlConnection(DataTestUtility.TCPConnectionString); + connection.Open(); + + using SqlDataAdapter dataAdapter = new SqlDataAdapter("SELECT * FROM dbo.Customers", connection); + using SqlCommandBuilder commandBuilder = new SqlCommandBuilder(dataAdapter); + + // Act + using SqlCommand command = getFunc(commandBuilder); + + // Assert + Assert.NotNull(command); } #region Utility_Methods diff --git a/src/Microsoft.Data.SqlClient/tests/ManualTests/SQL/Batch/BatchTests.cs b/src/Microsoft.Data.SqlClient/tests/ManualTests/SQL/Batch/BatchTests.netcore.cs similarity index 99% rename from src/Microsoft.Data.SqlClient/tests/ManualTests/SQL/Batch/BatchTests.cs rename to src/Microsoft.Data.SqlClient/tests/ManualTests/SQL/Batch/BatchTests.netcore.cs index a883eb9b88..175e81521b 100644 --- a/src/Microsoft.Data.SqlClient/tests/ManualTests/SQL/Batch/BatchTests.cs +++ b/src/Microsoft.Data.SqlClient/tests/ManualTests/SQL/Batch/BatchTests.netcore.cs @@ -2,6 +2,8 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. +#if NET + using System; using System.Collections.Generic; using System.Data; @@ -63,7 +65,6 @@ public static void ConnectionCanCreateBatch() } } -#if NET8_0_OR_GREATER [ConditionalFact(typeof(DataTestUtility), nameof(DataTestUtility.AreConnStringsSetup))] public static void SqlBatchCanCreateParameter() { @@ -81,7 +82,6 @@ public static void SqlBatchCanCreateParameter() batch.BatchCommands.Add(batchCommand); batch.ExecuteNonQuery(); } -#endif [ConditionalFact(typeof(DataTestUtility), nameof(DataTestUtility.AreConnStringsSetup))] public static void StoredProcedureBatchSupported() @@ -663,3 +663,5 @@ private static bool TryExecuteNonQueryCommand(string command) } } } + +#endif diff --git a/src/Microsoft.Data.SqlClient/tests/ManualTests/SQL/ConnectionPoolTest/ConnectionPoolTest.Debug.cs b/src/Microsoft.Data.SqlClient/tests/ManualTests/SQL/ConnectionPoolTest/ConnectionPoolTest.Debug.cs index 5881d4d5d3..130ef02934 100644 --- a/src/Microsoft.Data.SqlClient/tests/ManualTests/SQL/ConnectionPoolTest/ConnectionPoolTest.Debug.cs +++ b/src/Microsoft.Data.SqlClient/tests/ManualTests/SQL/ConnectionPoolTest/ConnectionPoolTest.Debug.cs @@ -1,4 +1,10 @@ -using System; +// 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. + +#if DEBUG + +using System; using System.Runtime.ExceptionServices; using System.Threading; using System.Threading.Tasks; @@ -204,3 +210,5 @@ public static void ReplacementConnectionObeys0TimeoutTest(string connectionStrin } } } + +#endif diff --git a/src/Microsoft.Data.SqlClient/tests/ManualTests/SQL/ConnectionPoolTest/TransactionPoolTest.cs b/src/Microsoft.Data.SqlClient/tests/ManualTests/SQL/ConnectionPoolTest/TransactionPoolTest.netfx.cs similarity index 99% rename from src/Microsoft.Data.SqlClient/tests/ManualTests/SQL/ConnectionPoolTest/TransactionPoolTest.cs rename to src/Microsoft.Data.SqlClient/tests/ManualTests/SQL/ConnectionPoolTest/TransactionPoolTest.netfx.cs index 5a6051625d..6ea47f6eb7 100644 --- a/src/Microsoft.Data.SqlClient/tests/ManualTests/SQL/ConnectionPoolTest/TransactionPoolTest.cs +++ b/src/Microsoft.Data.SqlClient/tests/ManualTests/SQL/ConnectionPoolTest/TransactionPoolTest.netfx.cs @@ -2,6 +2,8 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. +#if NETFRAMEWORK + using System.Transactions; using Xunit; @@ -103,3 +105,5 @@ public static void TransactionCleanupTest(string connectionString) } } } + +#endif diff --git a/src/Microsoft.Data.SqlClient/tests/ManualTests/SQL/SqlCommand/SqlCommandCancelTest.cs b/src/Microsoft.Data.SqlClient/tests/ManualTests/SQL/SqlCommand/SqlCommandCancelTest.cs index 9f20521f08..97c225c9ca 100644 --- a/src/Microsoft.Data.SqlClient/tests/ManualTests/SQL/SqlCommand/SqlCommandCancelTest.cs +++ b/src/Microsoft.Data.SqlClient/tests/ManualTests/SQL/SqlCommand/SqlCommandCancelTest.cs @@ -18,59 +18,43 @@ public static class SqlCommandCancelTest // Synapse: Remove dependency on Northwind database + WAITFOR not supported + ';' not supported [ConditionalFact(typeof(DataTestUtility), nameof(DataTestUtility.AreConnStringsSetup), nameof(DataTestUtility.IsNotAzureSynapse))] - public static void PlainCancelTest() - { + public static void PlainCancelTest_Tcp() => PlainCancel(tcp_connStr); - } [ConditionalFact(typeof(DataTestUtility), nameof(DataTestUtility.AreConnStringsSetup), nameof(DataTestUtility.IsNotAzureServer))] [PlatformSpecific(TestPlatforms.Windows)] - public static void PlainCancelTestNP() - { + public static void PlainCancelTest_NamedPipe() => PlainCancel(np_connStr); - } - + // Synapse: Remove dependency on Northwind database + WAITFOR not supported + ';' not supported [ConditionalFact(typeof(DataTestUtility), nameof(DataTestUtility.AreConnStringsSetup), nameof(DataTestUtility.IsNotAzureSynapse))] - public static void PlainMARSCancelTest() - { + public static void PlainCancelTest_TcpMars() => PlainCancel((new SqlConnectionStringBuilder(tcp_connStr) { MultipleActiveResultSets = true }).ConnectionString); - } [ConditionalFact(typeof(DataTestUtility), nameof(DataTestUtility.AreConnStringsSetup), nameof(DataTestUtility.IsNotAzureServer))] [PlatformSpecific(TestPlatforms.Windows)] - public static void PlainMARSCancelTestNP() - { + public static void PlainCancelTest_NamedPipeMars() => PlainCancel((new SqlConnectionStringBuilder(np_connStr) { MultipleActiveResultSets = true }).ConnectionString); - } // Synapse: Remove dependency on Northwind database + WAITFOR not supported + ';' not supported [ConditionalFact(typeof(DataTestUtility), nameof(DataTestUtility.AreConnStringsSetup), nameof(DataTestUtility.IsNotAzureSynapse))] - public static void PlainCancelTestAsync() - { + public static void PlainCancelTestAsync_Tcp() => PlainCancelAsync(tcp_connStr); - } [ConditionalFact(typeof(DataTestUtility), nameof(DataTestUtility.AreConnStringsSetup), nameof(DataTestUtility.IsNotAzureServer))] [PlatformSpecific(TestPlatforms.Windows)] - public static void PlainCancelTestAsyncNP() - { + public static void PlainCancelTestAsync_NamedPipe() => PlainCancelAsync(np_connStr); - } // Synapse: Remove dependency from Northwind database + WAITFOR not supported + ';' not supported. [ConditionalFact(typeof(DataTestUtility), nameof(DataTestUtility.AreConnStringsSetup), nameof(DataTestUtility.IsNotAzureSynapse))] - public static void PlainMARSCancelTestAsync() - { + public static void PlainCancelTestAsync_TcpMars() => PlainCancelAsync((new SqlConnectionStringBuilder(tcp_connStr) { MultipleActiveResultSets = true }).ConnectionString); - } [ConditionalFact(typeof(DataTestUtility), nameof(DataTestUtility.AreConnStringsSetup), nameof(DataTestUtility.IsNotAzureServer))] [PlatformSpecific(TestPlatforms.Windows)] - public static void PlainMARSCancelTestAsyncNP() - { + public static void PlainCancelTestAsync_NamedPipeMars() => PlainCancelAsync((new SqlConnectionStringBuilder(np_connStr) { MultipleActiveResultSets = true }).ConnectionString); - } private static void PlainCancel(string connString) { @@ -124,126 +108,90 @@ private static void PlainCancelAsync(string connString) // Synapse: Remove dependency from Northwind database + WAITFOR not supported + ';' not supported. [ConditionalFact(typeof(DataTestUtility), nameof(DataTestUtility.AreConnStringsSetup), nameof(DataTestUtility.IsNotAzureServer))] - public static void MultiThreadedCancel_NonAsync() - { + public static void MultiThreadedCancel_TcpSync() => MultiThreadedCancel(tcp_connStr, false); - } [ConditionalFact(typeof(DataTestUtility), nameof(DataTestUtility.AreConnStringsSetup), nameof(DataTestUtility.IsNotAzureServer))] [PlatformSpecific(TestPlatforms.Windows)] - public static void MultiThreadedCancel_NonAsyncNP() - { + public static void MultiThreadedCancel_NamedPipeSync() => MultiThreadedCancel(np_connStr, false); - } // Synapse: Remove dependency from Northwind database + WAITFOR not supported + ';' not supported. [ConditionalFact(typeof(DataTestUtility), nameof(DataTestUtility.AreConnStringsSetup), nameof(DataTestUtility.IsNotAzureSynapse))] - public static void MultiThreadedCancel_Async() - { + public static void MultiThreadedCancel_TcpAsync() => MultiThreadedCancel(tcp_connStr, true); - } [ConditionalFact(typeof(DataTestUtility), nameof(DataTestUtility.AreConnStringsSetup), nameof(DataTestUtility.IsNotAzureServer))] [PlatformSpecific(TestPlatforms.Windows)] - public static void MultiThreadedCancel_AsyncNP() - { + public static void MultiThreadedCancel_NamedPipeAsync() => MultiThreadedCancel(np_connStr, true); - } // Synapse: WAITFOR not supported + ';' not supported. [ConditionalFact(typeof(DataTestUtility), nameof(DataTestUtility.AreConnStringsSetup), nameof(DataTestUtility.IsNotAzureServer))] - public static void TimeoutCancelTcp() - { + public static void TimeoutCancel_Tcp() => TimeoutCancel(tcp_connStr); - } [ActiveIssue("https://github.com/dotnet/SqlClient/issues/3755")] [ConditionalFact(typeof(DataTestUtility), nameof(DataTestUtility.AreConnStringsSetup), nameof(DataTestUtility.IsNotAzureServer))] [PlatformSpecific(TestPlatforms.Windows)] - public static void TimeoutCancelNamedPipe() - { + public static void TimeoutCancel_NamedPipe() => TimeoutCancel(np_connStr); - } [ConditionalFact(typeof(DataTestUtility), nameof(DataTestUtility.AreConnStringsSetup))] - public static void CancelAndDisposePreparedCommand() - { + public static void CancelAndDisposePreparedCommand_Tcp() => CancelAndDisposePreparedCommand(tcp_connStr); - } [ConditionalFact(typeof(DataTestUtility), nameof(DataTestUtility.AreConnStringsSetup), nameof(DataTestUtility.IsNotAzureServer))] [PlatformSpecific(TestPlatforms.Windows)] - public static void CancelAndDisposePreparedCommandNP() - { + public static void CancelAndDisposePreparedCommand_NamedPipe() => CancelAndDisposePreparedCommand(np_connStr); - } [ConditionalFact(typeof(DataTestUtility), nameof(DataTestUtility.AreConnStringsSetup), nameof(DataTestUtility.IsNotAzureServer), nameof(DataTestUtility.IsNotNamedInstance))] - public static void TimeOutDuringReadTcp() - { + public static void TimeOutDuringRead_Tcp() => TimeOutDuringRead(tcp_connStr); - } [ConditionalFact(typeof(DataTestUtility), nameof(DataTestUtility.AreConnStringsSetup), nameof(DataTestUtility.IsNotAzureServer), nameof(DataTestUtility.IsNotNamedInstance))] [PlatformSpecific(TestPlatforms.Windows)] - public static void TimeOutDuringReadNamedPipe() - { + public static void TimeOutDuringRead_NamedPipe() => TimeOutDuringRead(np_connStr); - } // Synapse: WAITFOR not supported + ';' not supported. [ConditionalFact(typeof(DataTestUtility), nameof(DataTestUtility.AreConnStringsSetup), nameof(DataTestUtility.IsNotAzureSynapse))] - public static void CancelDoesNotWait() - { + public static void CancelDoesNotWait_Tcp() => CancelDoesNotWait(tcp_connStr); - } [ConditionalFact(typeof(DataTestUtility), nameof(DataTestUtility.AreConnStringsSetup), nameof(DataTestUtility.IsNotAzureServer))] [PlatformSpecific(TestPlatforms.Windows)] - public static void CancelDoesNotWaitNP() - { + public static void CancelDoesNotWait_NamedPipe() => CancelDoesNotWait(np_connStr); - } // Synapse: WAITFOR not supported + ';' not supported. [ConditionalFact(typeof(DataTestUtility), nameof(DataTestUtility.AreConnStringsSetup), nameof(DataTestUtility.IsNotAzureSynapse))] - public static void AsyncCancelDoesNotWait() - { - AsyncCancelDoesNotWait(tcp_connStr).Wait(); - } + public static Task CancelDoesNotWait_TcpAsync() => + CancelDoesNotWaitAsync(tcp_connStr); [ConditionalFact(typeof(DataTestUtility), nameof(DataTestUtility.AreConnStringsSetup), nameof(DataTestUtility.IsNotAzureServer))] [PlatformSpecific(TestPlatforms.Windows)] - public static void AsyncCancelDoesNotWaitNP() - { - AsyncCancelDoesNotWait(np_connStr).Wait(); - } + public static Task CancelDoesNotWait_NamedPipeAsync() => + CancelDoesNotWaitAsync(np_connStr); [ConditionalFact(typeof(DataTestUtility), nameof(DataTestUtility.AreConnStringsSetup))] - public static void TCPAttentionPacketTestTransaction() - { + public static void AttentionPacketTestTransaction_Tcp() => CancelFollowedByTransaction(tcp_connStr); - } [ConditionalFact(typeof(DataTestUtility), nameof(DataTestUtility.AreConnStringsSetup), nameof(DataTestUtility.IsNotAzureServer))] [PlatformSpecific(TestPlatforms.Windows)] - public static void NPAttentionPacketTestTransaction() - { + public static void AttentionPacketTestTransaction_NamedPipe() => CancelFollowedByTransaction(np_connStr); - } [ConditionalFact(typeof(DataTestUtility), nameof(DataTestUtility.AreConnStringsSetup), nameof(DataTestUtility.IsNotAzureServer))] - public static void TCPAttentionPacketTestAlerts() - { + public static void AttentionPacketTestAlerts_Tcp() => CancelFollowedByAlert(tcp_connStr); - } [ConditionalFact(typeof(DataTestUtility), nameof(DataTestUtility.AreConnStringsSetup), nameof(DataTestUtility.IsNotAzureServer))] [PlatformSpecific(TestPlatforms.Windows)] - public static void NPAttentionPacketTestAlerts() - { + public static void AttentionPacketTestAlerts_NamedPipe() => CancelFollowedByAlert(np_connStr); - } private static void CancelFollowedByTransaction(string constr) { @@ -378,7 +326,7 @@ private static void CancelAndDisposePreparedCommand(string constr) try { // Generate a query with a large number of results. - using (var command = new SqlCommand("select @P from sysobjects a cross join sysobjects b cross join sysobjects c cross join sysobjects d cross join sysobjects e cross join sysobjects f", connection)) + using (var command = new SqlCommand("select @P from sys.objects a cross join sys.objects b cross join sys.objects c cross join sys.objects d cross join sys.objects e cross join sys.objects f", connection)) { command.Parameters.Add(new SqlParameter("@P", SqlDbType.Int) { Value = expectedValue }); connection.Open(); @@ -530,7 +478,7 @@ private static void CancelDoesNotWait(string connStr) } } - private static async Task AsyncCancelDoesNotWait(string connStr) + private static async Task CancelDoesNotWaitAsync(string connStr) { const int delaySeconds = 30; const int cancelSeconds = 1; diff --git a/src/Microsoft.Data.SqlClient/tests/ManualTests/SQL/SqlDSEnumeratorTest/SqlDataSourceEnumeratorTest.cs b/src/Microsoft.Data.SqlClient/tests/ManualTests/SQL/SqlDSEnumeratorTest/SqlDataSourceEnumeratorTest.windows.cs similarity index 97% rename from src/Microsoft.Data.SqlClient/tests/ManualTests/SQL/SqlDSEnumeratorTest/SqlDataSourceEnumeratorTest.cs rename to src/Microsoft.Data.SqlClient/tests/ManualTests/SQL/SqlDSEnumeratorTest/SqlDataSourceEnumeratorTest.windows.cs index a81731c0a1..6835705c4d 100644 --- a/src/Microsoft.Data.SqlClient/tests/ManualTests/SQL/SqlDSEnumeratorTest/SqlDataSourceEnumeratorTest.cs +++ b/src/Microsoft.Data.SqlClient/tests/ManualTests/SQL/SqlDSEnumeratorTest/SqlDataSourceEnumeratorTest.windows.cs @@ -2,6 +2,8 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. +#if _WINDOWS + using System; using System.ComponentModel; using System.Linq; @@ -11,9 +13,6 @@ namespace Microsoft.Data.SqlClient.ManualTesting.Tests { -#if !NETFRAMEWORK - [System.Runtime.Versioning.SupportedOSPlatform("windows")] -#endif public class SqlDataSourceEnumeratorTest { private static bool IsEnvironmentAvailable() @@ -80,3 +79,5 @@ private SqlDataSourceEnumerator GetDSEnumerator() } } } + +#endif diff --git a/src/Microsoft.Data.SqlClient/tests/ManualTests/SQL/TransactionTest/DistributedTransactionTest.Windows.cs b/src/Microsoft.Data.SqlClient/tests/ManualTests/SQL/TransactionTest/DistributedTransactionTest.windows.cs similarity index 98% rename from src/Microsoft.Data.SqlClient/tests/ManualTests/SQL/TransactionTest/DistributedTransactionTest.Windows.cs rename to src/Microsoft.Data.SqlClient/tests/ManualTests/SQL/TransactionTest/DistributedTransactionTest.windows.cs index b4462840ca..85f4b288d5 100644 --- a/src/Microsoft.Data.SqlClient/tests/ManualTests/SQL/TransactionTest/DistributedTransactionTest.Windows.cs +++ b/src/Microsoft.Data.SqlClient/tests/ManualTests/SQL/TransactionTest/DistributedTransactionTest.windows.cs @@ -2,12 +2,12 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. +#if _WINDOWS + using System; using System.Data; -using System.Runtime.InteropServices; using System.Threading.Tasks; using System.Transactions; -using Microsoft.Data.SqlClient.TestUtilities; using Xunit; namespace Microsoft.Data.SqlClient.ManualTesting.Tests @@ -17,7 +17,7 @@ namespace Microsoft.Data.SqlClient.ManualTesting.Tests public class DistributedTransactionTestWindows { -#if NET + #if NET private static bool s_DelegatedTransactionCondition => DataTestUtility.AreConnStringsSetup() && DataTestUtility.IsNotAzureServer() && DataTestUtility.IsNotX86Architecture; [ConditionalFact(nameof(s_DelegatedTransactionCondition), Timeout = 10000)] @@ -43,7 +43,7 @@ public async Task Delegated_transaction_deadlock_in_SinglePhaseCommit() // Possible deadlock transaction.Commit(); } -#endif + #endif /** Test fails on SQL Managed Instance with error: * Failure: Item not found in collection @@ -56,9 +56,10 @@ public async Task Delegated_transaction_deadlock_in_SinglePhaseCommit() [ConditionalFact(nameof(s_EnlistedTransactionPreservedWhilePooledCondition), Timeout = 10000)] public async Task Test_EnlistedTransactionPreservedWhilePooled() { -#if NET + #if NET TransactionManager.ImplicitDistributedTransactions = true; -#endif + #endif + await RunTestSet(EnlistedTransactionPreservedWhilePooled); } @@ -181,3 +182,4 @@ private static async Task RunTestSet(Func TestCase) } } +#endif diff --git a/src/Microsoft.Data.SqlClient/tests/ManualTests/SQL/UdtTest/SqlServerTypesTest.cs b/src/Microsoft.Data.SqlClient/tests/ManualTests/SQL/UdtTest/SqlServerTypesTest.cs index 67a5cf2748..3719a09328 100644 --- a/src/Microsoft.Data.SqlClient/tests/ManualTests/SQL/UdtTest/SqlServerTypesTest.cs +++ b/src/Microsoft.Data.SqlClient/tests/ManualTests/SQL/UdtTest/SqlServerTypesTest.cs @@ -18,6 +18,21 @@ namespace Microsoft.Data.SqlClient.ManualTesting.Tests { public static class SqlServerTypesTest { + private const string BuiltInUdtSelectQuery = + @"SELECT " + + @" hierarchyid::Parse('/1/1/3/') AS col0, " + + @" geometry::Parse('LINESTRING (100 100, 20 180, 180 180)') AS col1, " + + @" geography::Parse('LINESTRING (-122.360 47.656, -122.343 47.656)') AS col2"; + + private const string GeometryBytesHexString = + "00000000010403000000000000000000594000000000000059400000000000003440000000000080" + + "66400000000000806640000000000080664001000000010000000001000000ffffffff0000000002"; + + private const string GeographyBytesHexString = + "e610000001148716d9cef7d34740d7a3703d0a975ec08716d9cef7d34740cba145b6f3955ec0"; + + private const string HierarchyIdBytesHexString = "5ade"; + // Synapse: Parse error at line: 1, column: 48: Incorrect syntax near 'hierarchyid'. [ConditionalFact(typeof(DataTestUtility), nameof(DataTestUtility.AreConnStringsSetup), nameof(DataTestUtility.IsNotAzureSynapse))] public static void GetSchemaTableTest() @@ -82,171 +97,123 @@ public static void TestUdtZeroByte() } // Synapse: Parse error at line: 1, column: 8: Incorrect syntax near 'hierarchyid'. - [ConditionalFact(typeof(DataTestUtility), nameof(DataTestUtility.AreConnStringsSetup), nameof(DataTestUtility.IsNotAzureSynapse))] - public static void TestUdtSqlDataReaderGetSqlBytesSequentialAccess() - { - TestUdtSqlDataReaderGetSqlBytes(CommandBehavior.SequentialAccess); - } - - // Synapse: Parse error at line: 1, column: 8: Incorrect syntax near 'hierarchyid'. - [ConditionalFact(typeof(DataTestUtility), nameof(DataTestUtility.AreConnStringsSetup), nameof(DataTestUtility.IsNotAzureSynapse))] - public static void TestUdtSqlDataReaderGetSqlBytes() + [ConditionalTheory(typeof(DataTestUtility), nameof(DataTestUtility.AreConnStringsSetup), nameof(DataTestUtility.IsNotAzureSynapse))] + [InlineData(CommandBehavior.Default)] + [InlineData(CommandBehavior.SequentialAccess)] + public static void TestUdtSqlDataReaderGetSqlBytes(CommandBehavior behavior) { - TestUdtSqlDataReaderGetSqlBytes(CommandBehavior.Default); - } + // Arrange + using SqlConnection connection = new SqlConnection(DataTestUtility.TCPConnectionString); + connection.Open(); - private static void TestUdtSqlDataReaderGetSqlBytes(CommandBehavior behavior) - { - using (SqlConnection connection = new SqlConnection(DataTestUtility.TCPConnectionString)) - { - connection.Open(); - SqlCommand command = connection.CreateCommand(); - command.CommandText = "select hierarchyid::Parse('/1/1/3/') as col0, geometry::Parse('LINESTRING (100 100, 20 180, 180 180)') as col1, geography::Parse('LINESTRING(-122.360 47.656, -122.343 47.656)') as col2"; - using (SqlDataReader reader = command.ExecuteReader(behavior)) - { - Assert.True(reader.Read()); + using SqlCommand command = connection.CreateCommand(); + command.CommandType = CommandType.Text; + command.CommandText = BuiltInUdtSelectQuery; - SqlBytes sqlBytes = null; + using SqlDataReader reader = command.ExecuteReader(behavior); + reader.Read(); - sqlBytes = reader.GetSqlBytes(0); - Assert.Equal("5ade", ToHexString(sqlBytes.Value)); + // Act / Assert + void ActAndAssert(int index, string expectedHexString) + { + // Act + SqlBytes sqlBytes = reader.GetSqlBytes(index); - sqlBytes = reader.GetSqlBytes(1); - Assert.Equal("0000000001040300000000000000000059400000000000005940000000000000344000000000008066400000000000806640000000000080664001000000010000000001000000ffffffff0000000002", ToHexString(sqlBytes.Value)); + // Assert + Assert.Equal(expectedHexString, ToHexString(sqlBytes.Value)); + } - sqlBytes = reader.GetSqlBytes(2); - Assert.Equal("e610000001148716d9cef7d34740d7a3703d0a975ec08716d9cef7d34740cba145b6f3955ec0", ToHexString(sqlBytes.Value)); + ActAndAssert(0, HierarchyIdBytesHexString); + ActAndAssert(1, GeometryBytesHexString); + ActAndAssert(2, GeographyBytesHexString); - if (behavior == CommandBehavior.Default) - { - sqlBytes = reader.GetSqlBytes(0); - Assert.Equal("5ade", ToHexString(sqlBytes.Value)); - } - } + // - In default behavior, ensure reading columns out of order works + if (behavior is CommandBehavior.Default) + { + ActAndAssert(0, HierarchyIdBytesHexString); } } // Synapse: Parse error at line: 1, column: 8: Incorrect syntax near 'hierarchyid'. - [ConditionalFact(typeof(DataTestUtility), nameof(DataTestUtility.AreConnStringsSetup), nameof(DataTestUtility.IsNotAzureSynapse))] - public static void TestUdtSqlDataReaderGetBytesSequentialAccess() + [ConditionalTheory(typeof(DataTestUtility), nameof(DataTestUtility.AreConnStringsSetup), nameof(DataTestUtility.IsNotAzureSynapse))] + [InlineData(CommandBehavior.Default)] + [InlineData(CommandBehavior.SequentialAccess)] + public static void TestUdtSqlDataReaderGetBytes(CommandBehavior behavior) { - TestUdtSqlDataReaderGetBytes(CommandBehavior.SequentialAccess); - } + // Arrange + using SqlConnection connection = new SqlConnection(DataTestUtility.TCPConnectionString); + connection.Open(); - // Synapse: Parse error at line: 1, column: 8: Incorrect syntax near 'hierarchyid'. - [ConditionalFact(typeof(DataTestUtility), nameof(DataTestUtility.AreConnStringsSetup), nameof(DataTestUtility.IsNotAzureSynapse))] - public static void TestUdtSqlDataReaderGetBytes() - { - TestUdtSqlDataReaderGetBytes(CommandBehavior.Default); - } + using SqlCommand command = connection.CreateCommand(); + command.CommandType = CommandType.Text; + command.CommandText = BuiltInUdtSelectQuery; - private static void TestUdtSqlDataReaderGetBytes(CommandBehavior behavior) - { - using (SqlConnection connection = new SqlConnection(DataTestUtility.TCPConnectionString)) - { - connection.Open(); - SqlCommand command = connection.CreateCommand(); - command.CommandText = "select hierarchyid::Parse('/1/1/3/') as col0, geometry::Parse('LINESTRING (100 100, 20 180, 180 180)') as col1, geography::Parse('LINESTRING(-122.360 47.656, -122.343 47.656)') as col2"; - using (SqlDataReader reader = command.ExecuteReader(behavior)) - { - Assert.True(reader.Read()); + using SqlDataReader reader = command.ExecuteReader(behavior); + reader.Read(); - int byteCount = 0; - byte[] bytes = null; + // Act / Assert + void ActAndAssert(int index, string expectedHexString) + { + // Act + int byteCount = (int)reader.GetBytes(index, 0, null, 0, 0); - byteCount = (int)reader.GetBytes(0, 0, null, 0, 0); - Assert.True(byteCount > 0); - bytes = new byte[byteCount]; - reader.GetBytes(0, 0, bytes, 0, bytes.Length); - Assert.Equal("5ade", ToHexString(bytes)); + byte[] bytes = new byte[byteCount]; + reader.GetBytes(index, 0, bytes, 0, bytes.Length); - byteCount = (int)reader.GetBytes(1, 0, null, 0, 0); - Assert.True(byteCount > 0); - bytes = new byte[byteCount]; - reader.GetBytes(1, 0, bytes, 0, bytes.Length); - Assert.Equal("0000000001040300000000000000000059400000000000005940000000000000344000000000008066400000000000806640000000000080664001000000010000000001000000ffffffff0000000002", ToHexString(bytes)); + // Assert + Assert.Equal(expectedHexString, ToHexString(bytes)); + } - byteCount = (int)reader.GetBytes(2, 0, null, 0, 0); - Assert.True(byteCount > 0); - bytes = new byte[byteCount]; - reader.GetBytes(2, 0, bytes, 0, bytes.Length); - Assert.Equal("e610000001148716d9cef7d34740d7a3703d0a975ec08716d9cef7d34740cba145b6f3955ec0", ToHexString(bytes)); + ActAndAssert(0, HierarchyIdBytesHexString); + ActAndAssert(1, GeometryBytesHexString); + ActAndAssert(2, GeographyBytesHexString); - if (behavior == CommandBehavior.Default) - { - byteCount = (int)reader.GetBytes(0, 0, null, 0, 0); - Assert.True(byteCount > 0); - bytes = new byte[byteCount]; - reader.GetBytes(0, 0, bytes, 0, bytes.Length); - Assert.Equal("5ade", ToHexString(bytes)); - } - } + // - In default behavior, ensure reading columns out of order works + if (behavior is CommandBehavior.Default) + { + ActAndAssert(0, HierarchyIdBytesHexString); } } // Synapse: Parse error at line: 1, column: 8: Incorrect syntax near 'hierarchyid'. - [ConditionalFact(typeof(DataTestUtility), nameof(DataTestUtility.AreConnStringsSetup), nameof(DataTestUtility.IsNotAzureSynapse))] - public static void TestUdtSqlDataReaderGetStreamSequentialAccess() + [ConditionalTheory(typeof(DataTestUtility), nameof(DataTestUtility.AreConnStringsSetup), nameof(DataTestUtility.IsNotAzureSynapse))] + [InlineData(CommandBehavior.Default)] + [InlineData(CommandBehavior.SequentialAccess)] + public static void TestUdtSqlDataReaderGetStream(CommandBehavior behavior) { - TestUdtSqlDataReaderGetStream(CommandBehavior.SequentialAccess); - } + // Arrange + using SqlConnection connection = new SqlConnection(DataTestUtility.TCPConnectionString); + connection.Open(); - // Synapse: Parse error at line: 1, column: 8: Incorrect syntax near 'hierarchyid'. - [ConditionalFact(typeof(DataTestUtility), nameof(DataTestUtility.AreConnStringsSetup), nameof(DataTestUtility.IsNotAzureSynapse))] - public static void TestUdtSqlDataReaderGetStream() - { - TestUdtSqlDataReaderGetStream(CommandBehavior.Default); - } + using SqlCommand command = connection.CreateCommand(); + command.CommandType = CommandType.Text; + command.CommandText = BuiltInUdtSelectQuery; - private static void TestUdtSqlDataReaderGetStream(CommandBehavior behavior) - { - using (SqlConnection connection = new SqlConnection(DataTestUtility.TCPConnectionString)) - { - connection.Open(); - SqlCommand command = connection.CreateCommand(); - command.CommandText = "select hierarchyid::Parse('/1/1/3/') as col0, geometry::Parse('LINESTRING (100 100, 20 180, 180 180)') as col1, geography::Parse('LINESTRING(-122.360 47.656, -122.343 47.656)') as col2"; - using (SqlDataReader reader = command.ExecuteReader(behavior)) - { - Assert.True(reader.Read()); + using SqlDataReader reader = command.ExecuteReader(behavior); + reader.Read(); - MemoryStream buffer = null; - byte[] bytes = null; + // Act / Assert + void ActAndAssert(int index, string expectedHexString) + { + // Act + MemoryStream buffer = new MemoryStream(); + using Stream stream = reader.GetStream(index); + stream.CopyTo(buffer); - buffer = new MemoryStream(); - using (Stream stream = reader.GetStream(0)) - { - stream.CopyTo(buffer); - } - bytes = buffer.ToArray(); - Assert.Equal("5ade", ToHexString(bytes)); + byte[] bytes = buffer.ToArray(); - buffer = new MemoryStream(); - using (Stream stream = reader.GetStream(1)) - { - stream.CopyTo(buffer); - } - bytes = buffer.ToArray(); - Assert.Equal("0000000001040300000000000000000059400000000000005940000000000000344000000000008066400000000000806640000000000080664001000000010000000001000000ffffffff0000000002", ToHexString(bytes)); + // Assert + Assert.Equal(expectedHexString, ToHexString(bytes)); + } - buffer = new MemoryStream(); - using (Stream stream = reader.GetStream(2)) - { - stream.CopyTo(buffer); - } - bytes = buffer.ToArray(); - Assert.Equal("e610000001148716d9cef7d34740d7a3703d0a975ec08716d9cef7d34740cba145b6f3955ec0", ToHexString(bytes)); + ActAndAssert(0, HierarchyIdBytesHexString); + ActAndAssert(1, GeometryBytesHexString); + ActAndAssert(2, GeographyBytesHexString); - if (behavior == CommandBehavior.Default) - { - buffer = new MemoryStream(); - using (Stream stream = reader.GetStream(0)) - { - stream.CopyTo(buffer); - } - bytes = buffer.ToArray(); - Assert.Equal("5ade", ToHexString(bytes)); - } - } + // - In default behavior, ensure reading columns out of order works + if (behavior is CommandBehavior.Default) + { + ActAndAssert(0, HierarchyIdBytesHexString); } } diff --git a/src/Microsoft.Data.SqlClient/tests/ManualTests/SQL/ParameterTest/SqlParameterTest_DebugMode.bsl b/src/Microsoft.Data.SqlClient/tests/ManualTests/SqlParameterTest_DebugMode.bsl similarity index 100% rename from src/Microsoft.Data.SqlClient/tests/ManualTests/SQL/ParameterTest/SqlParameterTest_DebugMode.bsl rename to src/Microsoft.Data.SqlClient/tests/ManualTests/SqlParameterTest_DebugMode.bsl diff --git a/src/Microsoft.Data.SqlClient/tests/ManualTests/SQL/ParameterTest/SqlParameterTest_DebugMode_Azure.bsl b/src/Microsoft.Data.SqlClient/tests/ManualTests/SqlParameterTest_DebugMode_Azure.bsl similarity index 100% rename from src/Microsoft.Data.SqlClient/tests/ManualTests/SQL/ParameterTest/SqlParameterTest_DebugMode_Azure.bsl rename to src/Microsoft.Data.SqlClient/tests/ManualTests/SqlParameterTest_DebugMode_Azure.bsl diff --git a/src/Microsoft.Data.SqlClient/tests/ManualTests/SQL/ParameterTest/SqlParameterTest_ReleaseMode.bsl b/src/Microsoft.Data.SqlClient/tests/ManualTests/SqlParameterTest_ReleaseMode.bsl similarity index 100% rename from src/Microsoft.Data.SqlClient/tests/ManualTests/SQL/ParameterTest/SqlParameterTest_ReleaseMode.bsl rename to src/Microsoft.Data.SqlClient/tests/ManualTests/SqlParameterTest_ReleaseMode.bsl diff --git a/src/Microsoft.Data.SqlClient/tests/ManualTests/SQL/ParameterTest/SqlParameterTest_ReleaseMode_Azure.bsl b/src/Microsoft.Data.SqlClient/tests/ManualTests/SqlParameterTest_ReleaseMode_Azure.bsl similarity index 100% rename from src/Microsoft.Data.SqlClient/tests/ManualTests/SQL/ParameterTest/SqlParameterTest_ReleaseMode_Azure.bsl rename to src/Microsoft.Data.SqlClient/tests/ManualTests/SqlParameterTest_ReleaseMode_Azure.bsl