diff --git a/.editorconfig b/.editorconfig index db85dde7fd..b2014e3974 100644 --- a/.editorconfig +++ b/.editorconfig @@ -169,3 +169,7 @@ dotnet_code_quality.ca1802.api_surface = private, internal [*.cs] dotnet_code_quality.CA2100.excluded_type_names_with_derived_types = Microsoft.Data.SqlClient.ManualTesting.Tests.* +dotnet_diagnostic.xUnit1031.severity=none +dotnet_diagnostic.xUnit1030.severity=none + + diff --git a/build.proj b/build.proj index 465f9264c3..d9e0146ba7 100644 --- a/build.proj +++ b/build.proj @@ -53,7 +53,6 @@ - @@ -64,7 +63,6 @@ - diff --git a/src/Microsoft.Data.SqlClient.sln b/src/Microsoft.Data.SqlClient.sln index c5b34945a0..327b6f4ff9 100644 --- a/src/Microsoft.Data.SqlClient.sln +++ b/src/Microsoft.Data.SqlClient.sln @@ -72,8 +72,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Data.SqlClient.Al EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "add-ons", "add-ons", "{C9726AED-D6A3-4AAC-BA04-92DD1F079594}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.DotNet.XUnitExtensions", "Microsoft.Data.SqlClient\tests\tools\Microsoft.DotNet.XUnitExtensions\Microsoft.DotNet.XUnitExtensions.csproj", "{FDA6971D-9F57-4DA4-B10A-261C91684CFC}" -EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "doc", "doc", "{ED952CF7-84DF-437A-B066-F516E9BE1C2C}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "snippets", "snippets", "{71F356DC-DFA3-4163-8BFE-D268722CE189}" diff --git a/src/Microsoft.Data.SqlClient/tests/FunctionalTests/AlwaysEncryptedTests/SqlColumnEncryptionCertificateStoreProviderShould.cs b/src/Microsoft.Data.SqlClient/tests/FunctionalTests/AlwaysEncryptedTests/SqlColumnEncryptionCertificateStoreProviderShould.cs index 5b7dd192ef..31c3504d84 100644 --- a/src/Microsoft.Data.SqlClient/tests/FunctionalTests/AlwaysEncryptedTests/SqlColumnEncryptionCertificateStoreProviderShould.cs +++ b/src/Microsoft.Data.SqlClient/tests/FunctionalTests/AlwaysEncryptedTests/SqlColumnEncryptionCertificateStoreProviderShould.cs @@ -303,7 +303,7 @@ public void TestAeadEncryptionReversal(string dataType, object data, Utility.CCo break; default: - Assert.True(false, "unexpected data type."); + Assert.Fail("unexpected data type."); break; } diff --git a/src/Microsoft.Data.SqlClient/tests/FunctionalTests/AmbientTransactionFailureTest.cs b/src/Microsoft.Data.SqlClient/tests/FunctionalTests/AmbientTransactionFailureTest.cs index 94cd0b8ddf..ed70dbd07d 100644 --- a/src/Microsoft.Data.SqlClient/tests/FunctionalTests/AmbientTransactionFailureTest.cs +++ b/src/Microsoft.Data.SqlClient/tests/FunctionalTests/AmbientTransactionFailureTest.cs @@ -3,6 +3,7 @@ // See the LICENSE file in the project root for more information. using System; +using System.Runtime.InteropServices; using System.Threading.Tasks; using System.Transactions; using Xunit; @@ -11,7 +12,7 @@ namespace Microsoft.Data.SqlClient.Tests { public class AmbientTransactionFailureTest { - + private static readonly bool s_isNotArmProcess = TestUtility.IsNotArmProcess; private static readonly string s_servername = Guid.NewGuid().ToString(); private static readonly string s_connectionStringWithEnlistAsDefault = $"Data Source={s_servername}; Integrated Security=true; Connect Timeout=1;"; private static readonly string s_connectionStringWithEnlistOff = $"Data Source={s_servername}; Integrated Security=true; Connect Timeout=1;Enlist=False"; @@ -73,7 +74,7 @@ public class AmbientTransactionFailureTest new object[] { EnlistConnectionInTransaction, s_connectionStringWithEnlistOff } }; - [ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsNotArmProcess))] // https://github.com/dotnet/corefx/issues/21598 + [ConditionalTheory(nameof(s_isNotArmProcess))] // https://github.com/dotnet/corefx/issues/21598 [MemberData(nameof(ExceptionTestDataForSqlException))] public void TestSqlException(Action connectAction, string connectionString) { diff --git a/src/Microsoft.Data.SqlClient/tests/tools/Microsoft.DotNet.XUnitExtensions/Extensions/AssertExtensions.cs b/src/Microsoft.Data.SqlClient/tests/FunctionalTests/AssertExtensions.cs similarity index 87% rename from src/Microsoft.Data.SqlClient/tests/tools/Microsoft.DotNet.XUnitExtensions/Extensions/AssertExtensions.cs rename to src/Microsoft.Data.SqlClient/tests/FunctionalTests/AssertExtensions.cs index 3368aec05a..d9fbb94ca3 100644 --- a/src/Microsoft.Data.SqlClient/tests/tools/Microsoft.DotNet.XUnitExtensions/Extensions/AssertExtensions.cs +++ b/src/Microsoft.Data.SqlClient/tests/FunctionalTests/AssertExtensions.cs @@ -1,10 +1,11 @@ -// Licensed to the .NET Foundation under one or more agreements. +// 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.Linq; using System.Runtime.InteropServices; using System.Threading.Tasks; +using Microsoft.Data.SqlClient.Tests; using Xunit; using Xunit.Sdk; @@ -12,7 +13,7 @@ namespace System { public static class AssertExtensions { - private static bool IsFullFramework => RuntimeInformation.FrameworkDescription.StartsWith(".NET Framework", StringComparison.Ordinal); + private static bool IsFullFramework => TestUtility.IsFullFramework; public static void Throws(Action action, string message) where T : Exception @@ -35,7 +36,7 @@ public static void Throws(string netCoreParamName, string netFxParamName, Act IsFullFramework ? netFxParamName : netCoreParamName; - if (!RuntimeInformation.FrameworkDescription.StartsWith(".NET Native", StringComparison.Ordinal)) + if (!TestUtility.NetNative) Assert.Equal(expectedParamName, exception.ParamName); } @@ -54,7 +55,7 @@ public static void Throws(string netCoreParamName, string netFxParamName, Fun IsFullFramework ? netFxParamName : netCoreParamName; - if (!RuntimeInformation.FrameworkDescription.StartsWith(".NET Native", StringComparison.Ordinal)) + if (!TestUtility.NetNative) Assert.Equal(expectedParamName, exception.ParamName); } @@ -63,7 +64,7 @@ public static T Throws(string paramName, Action action) { T exception = Assert.Throws(action); - if (!RuntimeInformation.FrameworkDescription.StartsWith(".NET Native", StringComparison.Ordinal)) + if (!TestUtility.NetNative) Assert.Equal(paramName, exception.ParamName); return exception; @@ -82,7 +83,7 @@ public static T Throws(string paramName, Func testCode) { T exception = Assert.Throws(testCode); - if (!RuntimeInformation.FrameworkDescription.StartsWith(".NET Native", StringComparison.Ordinal)) + if (!TestUtility.NetNative) Assert.Equal(paramName, exception.ParamName); return exception; @@ -93,7 +94,7 @@ public static async Task ThrowsAsync(string paramName, Func testCode { T exception = await Assert.ThrowsAsync(testCode); - if (!RuntimeInformation.FrameworkDescription.StartsWith(".NET Native", StringComparison.Ordinal)) + if (!TestUtility.NetNative) Assert.Equal(paramName, exception.ParamName); return exception; @@ -298,24 +299,5 @@ public static void GreaterThanOrEqualTo(T actual, T greaterThanOrEqualTo, str throw new XunitException(AddOptionalUserMessage($"Expected: {actual} to be greater than or equal to {greaterThanOrEqualTo}", userMessage)); } - /// - /// Validates that the actual byte array is equal to the expected byte array. XUnit only displays the first 5 values - /// of each collection if the test fails. This doesn't display at what point or how the equality assertion failed. - /// - /// The byte array that should be equal to. - /// - public static void Equal(byte[] expected, byte[] actual) - { - try - { - Assert.Equal(expected, actual); - } - catch (AssertActualExpectedException) - { - string expectedString = string.Join(", ", expected); - string actualString = string.Join(", ", actual); - throw new AssertActualExpectedException(expectedString, actualString, null); - } - } } } diff --git a/src/Microsoft.Data.SqlClient/tests/FunctionalTests/DataCommon/TestUtility.cs b/src/Microsoft.Data.SqlClient/tests/FunctionalTests/DataCommon/TestUtility.cs new file mode 100644 index 0000000000..259dc8817a --- /dev/null +++ b/src/Microsoft.Data.SqlClient/tests/FunctionalTests/DataCommon/TestUtility.cs @@ -0,0 +1,16 @@ +// 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.Runtime.InteropServices; + +namespace Microsoft.Data.SqlClient.Tests +{ + public static class TestUtility + { + public static readonly bool IsNotArmProcess = RuntimeInformation.ProcessArchitecture != Architecture.Arm; + public static bool IsFullFramework => RuntimeInformation.FrameworkDescription.StartsWith(".NET Framework"); + public static bool NetNative => RuntimeInformation.FrameworkDescription.StartsWith(".NET Native"); + } +} diff --git a/src/Microsoft.Data.SqlClient/tests/FunctionalTests/Microsoft.Data.SqlClient.Tests.csproj b/src/Microsoft.Data.SqlClient/tests/FunctionalTests/Microsoft.Data.SqlClient.Tests.csproj index 117c4ea9f0..78d93ab108 100644 --- a/src/Microsoft.Data.SqlClient/tests/FunctionalTests/Microsoft.Data.SqlClient.Tests.csproj +++ b/src/Microsoft.Data.SqlClient/tests/FunctionalTests/Microsoft.Data.SqlClient.Tests.csproj @@ -25,8 +25,10 @@ + + @@ -66,6 +68,25 @@ + + + + runtime; build; native; contentfiles; analyzers; buildtransitive + all + + + + + runtime; build; native; contentfiles; analyzers; buildtransitive + all + + + runtime; build; native; contentfiles; analyzers; buildtransitive + all + + + + @@ -92,21 +113,21 @@ TDS - - Microsoft.DotNet.XUnitExtensions - - - - + + + PreserveNewest + xunit.runner.json + + diff --git a/src/Microsoft.Data.SqlClient/tests/FunctionalTests/SqlBulkCopyColumnMappingCollectionTest.cs b/src/Microsoft.Data.SqlClient/tests/FunctionalTests/SqlBulkCopyColumnMappingCollectionTest.cs index 3ac3d8a279..66ebe02078 100644 --- a/src/Microsoft.Data.SqlClient/tests/FunctionalTests/SqlBulkCopyColumnMappingCollectionTest.cs +++ b/src/Microsoft.Data.SqlClient/tests/FunctionalTests/SqlBulkCopyColumnMappingCollectionTest.cs @@ -5,7 +5,6 @@ using System; using System.Collections; using System.Diagnostics; - using Xunit; namespace Microsoft.Data.SqlClient.Tests @@ -420,7 +419,7 @@ public void InsertAndClear_BehavesAsExpected() Assert.Same(item3, list[2]); list.Clear(); - Assert.Equal(0, list.Count); + Assert.Empty(list); list.Add(item1); list.Add(item3); @@ -435,7 +434,7 @@ public void InsertAndClear_BehavesAsExpected() Assert.Same(item3, list[2]); list.Clear(); - Assert.Equal(0, list.Count); + Assert.Empty(list); } [Fact] @@ -463,11 +462,11 @@ public void Remove_BehavesAsExpected() IList list = CreateCollection(item1, item2); list.Remove(item1); - Assert.Equal(1, list.Count); + Assert.Single(list); Assert.Same(item2, list[0]); list.Remove(item2); - Assert.Equal(0, list.Count); + Assert.Empty(list); AssertExtensions.Throws(null, () => list.Remove(item2)); AssertExtensions.Throws(null, () => list.Remove(new SqlBulkCopyColumnMapping(2, 2))); @@ -504,11 +503,11 @@ public void RemoveAt_BehavesAsExpected() Assert.Same(item3, list[1]); list.RemoveAt(1); - Assert.Equal(1, list.Count); + Assert.Single(list); Assert.Same(item2, list[0]); list.RemoveAt(0); - Assert.Equal(0, list.Count); + Assert.Empty(list); } [Fact] diff --git a/src/Microsoft.Data.SqlClient/tests/FunctionalTests/SqlBulkCopyColumnOrderHintCollectionTest.cs b/src/Microsoft.Data.SqlClient/tests/FunctionalTests/SqlBulkCopyColumnOrderHintCollectionTest.cs index b6104335dd..19a9948bf5 100644 --- a/src/Microsoft.Data.SqlClient/tests/FunctionalTests/SqlBulkCopyColumnOrderHintCollectionTest.cs +++ b/src/Microsoft.Data.SqlClient/tests/FunctionalTests/SqlBulkCopyColumnOrderHintCollectionTest.cs @@ -395,7 +395,7 @@ public void InsertAndClear_BehavesAsExpected() Assert.Same(item3, list[2]); list.Clear(); - Assert.Equal(0, list.Count); + Assert.Empty(list); list.Add(item1); list.Add(item3); @@ -410,7 +410,7 @@ public void InsertAndClear_BehavesAsExpected() Assert.Same(item3, list[2]); list.Clear(); - Assert.Equal(0, list.Count); + Assert.Empty(list); } [Fact] @@ -434,11 +434,11 @@ public void Remove_BehavesAsExpected() IList list = CreateCollection(item1, item2); list.Remove(item1); - Assert.Equal(1, list.Count); + Assert.Single(list); Assert.Same(item2, list[0]); list.Remove(item2); - Assert.Equal(0, list.Count); + Assert.Empty(list); AssertExtensions.Throws(null, () => list.Remove(item2)); AssertExtensions.Throws(null, () => list.Remove(new SqlBulkCopyColumnOrderHint("column4", SortOrder.Ascending))); @@ -473,11 +473,11 @@ public void RemoveAt_BehavesAsExpected() Assert.Same(item2, list[0]); Assert.Same(item3, list[1]); list.RemoveAt(1); - Assert.Equal(1, list.Count); + Assert.Single(list); Assert.Same(item2, list[0]); list.RemoveAt(0); - Assert.Equal(0, list.Count); + Assert.Empty(list); } [Fact] diff --git a/src/Microsoft.Data.SqlClient/tests/FunctionalTests/SqlConnectionBasicTests.cs b/src/Microsoft.Data.SqlClient/tests/FunctionalTests/SqlConnectionBasicTests.cs index 01c2f2c050..70c94eb928 100644 --- a/src/Microsoft.Data.SqlClient/tests/FunctionalTests/SqlConnectionBasicTests.cs +++ b/src/Microsoft.Data.SqlClient/tests/FunctionalTests/SqlConnectionBasicTests.cs @@ -8,6 +8,7 @@ using System.Diagnostics; using System.Globalization; using System.Reflection; +using System.Runtime.InteropServices; using System.Security; using System.Threading; using System.Threading.Tasks; @@ -26,8 +27,7 @@ public void ConnectionTest() connection.Open(); } - [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotArmProcess))] - [ActiveIssue(4830, TestPlatforms.AnyUnix)] + [ConditionalFact(typeof(TestUtility), nameof(TestUtility.IsNotArmProcess))] [PlatformSpecific(TestPlatforms.Windows)] public void IntegratedAuthConnectionTest() { @@ -38,7 +38,7 @@ public void IntegratedAuthConnectionTest() connection.Open(); } - [ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsNotArmProcess))] + [ConditionalTheory(typeof(TestUtility), nameof(TestUtility.IsNotArmProcess))] [InlineData(40613)] [InlineData(42108)] [InlineData(42109)] @@ -58,7 +58,7 @@ public async Task TransientFaultTestAsync(uint errorCode) Assert.Equal(ConnectionState.Open, connection.State); } - [ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsNotArmProcess))] + [ConditionalTheory(typeof(TestUtility), nameof(TestUtility.IsNotArmProcess))] [InlineData(40613)] [InlineData(42108)] [InlineData(42109)] @@ -81,11 +81,11 @@ public void TransientFaultTest(uint errorCode) } catch (Exception e) { - Assert.False(true, e.Message); + Assert.Fail(e.Message); } } - [ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsNotArmProcess))] + [ConditionalTheory(typeof(TestUtility), nameof(TestUtility.IsNotArmProcess))] [InlineData(40613)] [InlineData(42108)] [InlineData(42109)] @@ -107,7 +107,7 @@ public void TransientFaultDisabledTestAsync(uint errorCode) Assert.Equal(ConnectionState.Closed, connection.State); } - [ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsNotArmProcess))] + [ConditionalTheory(typeof(TestUtility), nameof(TestUtility.IsNotArmProcess))] [InlineData(40613)] [InlineData(42108)] [InlineData(42109)] @@ -316,7 +316,7 @@ public async void ConnectionTimeoutTestAsync(int timeout) try { //an asyn call with a timeout token to cancel the operation after the specific time - using CancellationTokenSource cts = new CancellationTokenSource(timeout * 1000); + using CancellationTokenSource cts = new CancellationTokenSource(timeout * 1000); timer.Start(); await connection.OpenAsync(cts.Token).ConfigureAwait(false); } diff --git a/src/Microsoft.Data.SqlClient/tests/FunctionalTests/SqlConnectionTest.RetrieveStatistics.cs b/src/Microsoft.Data.SqlClient/tests/FunctionalTests/SqlConnectionTest.RetrieveStatistics.cs index 6e08b3e91d..a18a4b78da 100644 --- a/src/Microsoft.Data.SqlClient/tests/FunctionalTests/SqlConnectionTest.RetrieveStatistics.cs +++ b/src/Microsoft.Data.SqlClient/tests/FunctionalTests/SqlConnectionTest.RetrieveStatistics.cs @@ -181,13 +181,13 @@ public void RetrieveStatistics_Clear_Success() d.Clear(); Assert.Empty(d); - Assert.Equal(0, d.Count); + Assert.Empty(d); Assert.Empty(d.Keys); - Assert.Equal(0, d.Keys.Count); + Assert.Empty(d.Keys); Assert.Empty(d.Values); - Assert.Equal(0, d.Values.Count); + Assert.Empty(d.Values); } [Fact] diff --git a/src/Microsoft.Data.SqlClient/tests/FunctionalTests/SqlDataRecordTest.cs b/src/Microsoft.Data.SqlClient/tests/FunctionalTests/SqlDataRecordTest.cs index 77546de525..87f6c167ec 100644 --- a/src/Microsoft.Data.SqlClient/tests/FunctionalTests/SqlDataRecordTest.cs +++ b/src/Microsoft.Data.SqlClient/tests/FunctionalTests/SqlDataRecordTest.cs @@ -70,7 +70,7 @@ public void SqlRecordFillTest() char[] expectedValue = new char[] { 'a', 'b', 'e', 'f', 'g' }; Assert.Equal(expectedValue.Length, record.GetChars(3, 0, cb2, 0, 5)); - Assert.Equal(expectedValue, new string(cb2, 0, (int)record.GetChars(3, 0, null, 0, 0))); + Assert.Equal(expectedValue, new string(cb2, 0, (int)record.GetChars(3, 0, null, 0, 0)).ToCharArray()); record.SetString(3, ""); string xyz = "xyz"; diff --git a/src/Microsoft.Data.SqlClient/tests/FunctionalTests/SqlErrorTest.cs b/src/Microsoft.Data.SqlClient/tests/FunctionalTests/SqlErrorTest.cs index 13b78449f4..c8264eb446 100644 --- a/src/Microsoft.Data.SqlClient/tests/FunctionalTests/SqlErrorTest.cs +++ b/src/Microsoft.Data.SqlClient/tests/FunctionalTests/SqlErrorTest.cs @@ -33,7 +33,7 @@ public static void SqlErrorSerializationTest() } catch (Exception ex) { - Assert.False(true, $"Unexpected Exception occurred: {ex.Message}"); + Assert.Fail($"Unexpected Exception occurred: {ex.Message}"); } } diff --git a/src/Microsoft.Data.SqlClient/tests/FunctionalTests/SqlExceptionTest.cs b/src/Microsoft.Data.SqlClient/tests/FunctionalTests/SqlExceptionTest.cs index 71975db7a5..204ab379c1 100644 --- a/src/Microsoft.Data.SqlClient/tests/FunctionalTests/SqlExceptionTest.cs +++ b/src/Microsoft.Data.SqlClient/tests/FunctionalTests/SqlExceptionTest.cs @@ -50,7 +50,7 @@ public static void SqlExcpetionSerializationTest() } catch (Exception ex) { - Assert.False(true, $"Unexpected Exception occurred: {ex.Message}"); + Assert.Fail($"Unexpected Exception occurred: {ex.Message}"); } } } diff --git a/src/Microsoft.Data.SqlClient/tests/FunctionalTests/SqlHelperTest.cs b/src/Microsoft.Data.SqlClient/tests/FunctionalTests/SqlHelperTest.cs index 087e5b5c57..44286b8c0e 100644 --- a/src/Microsoft.Data.SqlClient/tests/FunctionalTests/SqlHelperTest.cs +++ b/src/Microsoft.Data.SqlClient/tests/FunctionalTests/SqlHelperTest.cs @@ -50,7 +50,7 @@ void handleUnobservedException(object o, UnobservedTaskExceptionEventArgs a) if (unobservedExceptionHappend) //Save doing string interpolation in the happy case { var e = UnwrapException(unhandledException); - Assert.False(true, $"Did not expect an unobserved exception, but found a {e?.GetType()} with message \"{e?.Message}\""); + Assert.Fail($"Did not expect an unobserved exception, but found a {e?.GetType()} with message \"{e?.Message}\""); } } finally diff --git a/src/Microsoft.Data.SqlClient/tests/ManualTests/AlwaysEncrypted/AKVUnitTests.cs b/src/Microsoft.Data.SqlClient/tests/ManualTests/AlwaysEncrypted/AKVUnitTests.cs index a9d69cd6e2..85192076fc 100644 --- a/src/Microsoft.Data.SqlClient/tests/ManualTests/AlwaysEncrypted/AKVUnitTests.cs +++ b/src/Microsoft.Data.SqlClient/tests/ManualTests/AlwaysEncrypted/AKVUnitTests.cs @@ -59,7 +59,7 @@ private static void ValidateAKVTraces(List eventData, Gui } break; default: - Assert.False(true, "Unexpected event occurred: " + item.Message); + Assert.Fail("Unexpected event occurred: " + item.Message); break; } }); diff --git a/src/Microsoft.Data.SqlClient/tests/ManualTests/AlwaysEncrypted/ApiShould.cs b/src/Microsoft.Data.SqlClient/tests/ManualTests/AlwaysEncrypted/ApiShould.cs index 62db90fce0..6e92b4f479 100644 --- a/src/Microsoft.Data.SqlClient/tests/ManualTests/AlwaysEncrypted/ApiShould.cs +++ b/src/Microsoft.Data.SqlClient/tests/ManualTests/AlwaysEncrypted/ApiShould.cs @@ -2918,7 +2918,7 @@ private void EndExecuteReaderAsyncCallBack(IAsyncResult asyncResult) catch (Exception e) { testAsyncCallBackStateObject.Completion.SetException(e); - Assert.True(false, $"{e.Message}"); + Assert.Fail($"{e.Message}"); } } diff --git a/src/Microsoft.Data.SqlClient/tests/ManualTests/AlwaysEncrypted/ConversionTests.cs b/src/Microsoft.Data.SqlClient/tests/ManualTests/AlwaysEncrypted/ConversionTests.cs index 04c661902d..d0b1bfd076 100644 --- a/src/Microsoft.Data.SqlClient/tests/ManualTests/AlwaysEncrypted/ConversionTests.cs +++ b/src/Microsoft.Data.SqlClient/tests/ManualTests/AlwaysEncrypted/ConversionTests.cs @@ -524,7 +524,7 @@ List GenerateOutOfRangeValuesForType(SqlDbType type, int length list.Add(new ValueErrorTuple(Single.Epsilon, false)); break; default: - Assert.True(false, "We should never get here"); + Assert.Fail("We should never get here"); break; } @@ -562,7 +562,7 @@ private void ExecuteAndCheckForError(SqlCommand sqlCmd, bool expectError) try { sqlCmd.ExecuteNonQuery(); - Assert.True(false, "We should have gotten an error but passed instead."); + Assert.Fail("We should have gotten an error but passed instead."); } catch (Exception e) { diff --git a/src/Microsoft.Data.SqlClient/tests/ManualTests/AlwaysEncrypted/End2EndSmokeTests.cs b/src/Microsoft.Data.SqlClient/tests/ManualTests/AlwaysEncrypted/End2EndSmokeTests.cs index ea4b0171eb..874c225d9f 100644 --- a/src/Microsoft.Data.SqlClient/tests/ManualTests/AlwaysEncrypted/End2EndSmokeTests.cs +++ b/src/Microsoft.Data.SqlClient/tests/ManualTests/AlwaysEncrypted/End2EndSmokeTests.cs @@ -106,7 +106,7 @@ public void TestSelectOnEncryptedNonEncryptedColumnsWithEncryptedParameters(stri break; default: - Assert.True(false, "FAILED: No other data type is supported."); + Assert.Fail("FAILED: No other data type is supported."); break; } diff --git a/src/Microsoft.Data.SqlClient/tests/ManualTests/AlwaysEncrypted/TestFixtures/DatabaseHelper.cs b/src/Microsoft.Data.SqlClient/tests/ManualTests/AlwaysEncrypted/TestFixtures/DatabaseHelper.cs index 9cea6b8239..1ebdcfe04d 100644 --- a/src/Microsoft.Data.SqlClient/tests/ManualTests/AlwaysEncrypted/TestFixtures/DatabaseHelper.cs +++ b/src/Microsoft.Data.SqlClient/tests/ManualTests/AlwaysEncrypted/TestFixtures/DatabaseHelper.cs @@ -157,7 +157,7 @@ public static void CompareResults(SqlDataReader sqlDataReader, string[] paramete break; default: - Assert.True(false, "FAILED: unexpected data type."); + Assert.Fail("FAILED: unexpected data type."); break; } diff --git a/src/Microsoft.Data.SqlClient/tests/ManualTests/DataCommon/DataTestUtility.cs b/src/Microsoft.Data.SqlClient/tests/ManualTests/DataCommon/DataTestUtility.cs index b61486ddf8..07f866f98b 100644 --- a/src/Microsoft.Data.SqlClient/tests/ManualTests/DataCommon/DataTestUtility.cs +++ b/src/Microsoft.Data.SqlClient/tests/ManualTests/DataCommon/DataTestUtility.cs @@ -21,6 +21,7 @@ using System.Net.NetworkInformation; using System.Text; using System.Security.Principal; +using System.Runtime.InteropServices; namespace Microsoft.Data.SqlClient.ManualTesting.Tests { @@ -77,6 +78,10 @@ public static class DataTestUtility public const string AKVEventSourceName = "Microsoft.Data.SqlClient.AlwaysEncrypted.AzureKeyVaultProvider.EventSource"; private const string ManagedNetworkingAppContextSwitch = "Switch.Microsoft.Data.SqlClient.UseManagedNetworkingOnWindows"; + // uap constant + const long APPMODEL_ERROR_NO_PACKAGE = 15700L; + public static readonly bool IsRunningAsUWPApp = RunningAsUWPApp(); + private static Dictionary AvailableDatabases; private static BaseEventListener TraceListener; @@ -302,6 +307,8 @@ public static bool GetSQLServerStatusOnTDS8(string connectionString) return isTDS8Supported; } + public static bool IsNotX86Architecture => RuntimeInformation.ProcessArchitecture != Architecture.X86; + public static bool IsDatabasePresent(string name) { AvailableDatabases = AvailableDatabases ?? new Dictionary(); @@ -734,7 +741,7 @@ public static TException ExpectFailure(Action actionThatFails, strin try { actionThatFails(); - Assert.False(true, "ERROR: Did not get expected exception"); + Assert.Fail("ERROR: Did not get expected exception"); return null; } catch (Exception ex) @@ -755,7 +762,7 @@ public static TException ExpectFailure(Action actio try { actionThatFails(); - Assert.False(true, "ERROR: Did not get expected exception"); + Assert.Fail("ERROR: Did not get expected exception"); return null; } catch (Exception ex) @@ -776,7 +783,7 @@ public static TException ExpectFailure Utf8String - - Microsoft.DotNet.XUnitExtensions - - - - - - - - + + + + + + + + + + + + + + runtime; build; native; contentfiles; analyzers; buildtransitive + all + + + runtime; build; native; contentfiles; analyzers; buildtransitive + all + + + runtime; build; native; contentfiles; analyzers; buildtransitive + all + + + @@ -331,5 +359,9 @@ Always + + PreserveNewest + xunit.runner.json + diff --git a/src/Microsoft.Data.SqlClient/tests/ManualTests/SQL/AsyncTest/AsyncTest.cs b/src/Microsoft.Data.SqlClient/tests/ManualTests/SQL/AsyncTest/AsyncTest.cs index 080a66b394..8208f7e496 100644 --- a/src/Microsoft.Data.SqlClient/tests/ManualTests/SQL/AsyncTest/AsyncTest.cs +++ b/src/Microsoft.Data.SqlClient/tests/ManualTests/SQL/AsyncTest/AsyncTest.cs @@ -10,7 +10,7 @@ namespace Microsoft.Data.SqlClient.ManualTesting.Tests { public static class AsyncTest { - [ActiveIssue(5533)] // Async Operations slower than Sync operations + [ActiveIssue("5533")] // Async Operations slower than Sync operations [ConditionalFact(typeof(DataTestUtility), nameof(DataTestUtility.AreConnStringsSetup))] public static void TestReadAsyncTimeConsumed() { diff --git a/src/Microsoft.Data.SqlClient/tests/ManualTests/SQL/AsyncTest/AsyncTimeoutTest.cs b/src/Microsoft.Data.SqlClient/tests/ManualTests/SQL/AsyncTest/AsyncTimeoutTest.cs index b516fa1a11..14abfea409 100644 --- a/src/Microsoft.Data.SqlClient/tests/ManualTests/SQL/AsyncTest/AsyncTimeoutTest.cs +++ b/src/Microsoft.Data.SqlClient/tests/ManualTests/SQL/AsyncTest/AsyncTimeoutTest.cs @@ -174,7 +174,7 @@ private static async Task QueryAndValidate(AsyncAPI api, int index, string delay } catch (Exception ex) { - Assert.False(true, "Exception occurred: " + ex.Message); + Assert.Fail("Exception occurred: " + ex.Message); } } break; diff --git a/src/Microsoft.Data.SqlClient/tests/ManualTests/SQL/AsyncTest/XmlReaderAsyncTest.cs b/src/Microsoft.Data.SqlClient/tests/ManualTests/SQL/AsyncTest/XmlReaderAsyncTest.cs index 9d425b1b75..af5045e6ad 100644 --- a/src/Microsoft.Data.SqlClient/tests/ManualTests/SQL/AsyncTest/XmlReaderAsyncTest.cs +++ b/src/Microsoft.Data.SqlClient/tests/ManualTests/SQL/AsyncTest/XmlReaderAsyncTest.cs @@ -89,7 +89,7 @@ public static async void MoveToContentAsyncTest() } catch (Exception ex) { - Assert.False(true, "Exception occurred: " + ex.Message); + Assert.Fail("Exception occurred: " + ex.Message); } } } diff --git a/src/Microsoft.Data.SqlClient/tests/ManualTests/SQL/ConnectionTestWithSSLCert/CertificateTest.cs b/src/Microsoft.Data.SqlClient/tests/ManualTests/SQL/ConnectionTestWithSSLCert/CertificateTest.cs index 64df0c0677..b8ac6fe27f 100644 --- a/src/Microsoft.Data.SqlClient/tests/ManualTests/SQL/ConnectionTestWithSSLCert/CertificateTest.cs +++ b/src/Microsoft.Data.SqlClient/tests/ManualTests/SQL/ConnectionTestWithSSLCert/CertificateTest.cs @@ -128,7 +128,7 @@ public void OpeningConnectionWitHNICTest() } } - [ActiveIssue(26934)] + [ActiveIssue("26934")] [ConditionalFact(typeof(DataTestUtility), nameof(DataTestUtility.AreConnStringsSetup), nameof(DataTestUtility.UseManagedSNIOnWindows), nameof(DataTestUtility.IsNotAzureServer))] [PlatformSpecific(TestPlatforms.Windows)] public void RemoteCertificateNameMismatchErrorTest() diff --git a/src/Microsoft.Data.SqlClient/tests/ManualTests/SQL/ConnectivityTests/AADConnectionTest.cs b/src/Microsoft.Data.SqlClient/tests/ManualTests/SQL/ConnectivityTests/AADConnectionTest.cs index 06080a9ca6..da1b59132c 100644 --- a/src/Microsoft.Data.SqlClient/tests/ManualTests/SQL/ConnectivityTests/AADConnectionTest.cs +++ b/src/Microsoft.Data.SqlClient/tests/ManualTests/SQL/ConnectivityTests/AADConnectionTest.cs @@ -647,7 +647,7 @@ public static void ADInteractiveUsingSSPI() // Test passes locally everytime, but in pieplines fails randomly with uncertainity. // e.g. Second AAD connection too slow (802ms)! (More than 30% of the first (576ms).) - [ActiveIssue(16058)] + [ActiveIssue("16058")] [ConditionalFact(nameof(IsAADConnStringsSetup))] public static void ConnectionSpeed() { diff --git a/src/Microsoft.Data.SqlClient/tests/ManualTests/SQL/ConnectivityTests/ConnectivityTest.cs b/src/Microsoft.Data.SqlClient/tests/ManualTests/SQL/ConnectivityTests/ConnectivityTest.cs index 15aa818c37..cd373757a4 100644 --- a/src/Microsoft.Data.SqlClient/tests/ManualTests/SQL/ConnectivityTests/ConnectivityTest.cs +++ b/src/Microsoft.Data.SqlClient/tests/ManualTests/SQL/ConnectivityTests/ConnectivityTest.cs @@ -83,7 +83,7 @@ public static void EnvironmentHostNameSPIDTest() // Confirm Server Process Id stays the same after query execution Assert.Equal(sessionSpid, sqlConnection.ServerProcessId); } - Assert.True(false, "No non-empty hostname found for the application"); + Assert.Fail("No non-empty hostname found for the application"); } [ConditionalFact(typeof(DataTestUtility), nameof(DataTestUtility.AreConnStringsSetup))] diff --git a/src/Microsoft.Data.SqlClient/tests/ManualTests/SQL/DataReaderTest/DataReaderTest.cs b/src/Microsoft.Data.SqlClient/tests/ManualTests/SQL/DataReaderTest/DataReaderTest.cs index f3bf37d2d4..a9ebe4cdd1 100644 --- a/src/Microsoft.Data.SqlClient/tests/ManualTests/SQL/DataReaderTest/DataReaderTest.cs +++ b/src/Microsoft.Data.SqlClient/tests/ManualTests/SQL/DataReaderTest/DataReaderTest.cs @@ -161,7 +161,7 @@ public static void CollatedDataReaderTest() } catch (SqlException e) { - Assert.True(false, $"Unexpected Exception occurred: {e.Message}"); + Assert.Fail($"Unexpected Exception occurred: {e.Message}"); } finally { diff --git a/src/Microsoft.Data.SqlClient/tests/ManualTests/SQL/DataStreamTest/DataStreamTest.cs b/src/Microsoft.Data.SqlClient/tests/ManualTests/SQL/DataStreamTest/DataStreamTest.cs index 30a1505442..cc11acc1da 100644 --- a/src/Microsoft.Data.SqlClient/tests/ManualTests/SQL/DataStreamTest/DataStreamTest.cs +++ b/src/Microsoft.Data.SqlClient/tests/ManualTests/SQL/DataStreamTest/DataStreamTest.cs @@ -31,7 +31,7 @@ public static void RunAllTestsForSingleServer_NP() } } - [ActiveIssue(5540)] + [ActiveIssue("5540")] [ConditionalFact(typeof(DataTestUtility), nameof(DataTestUtility.AreConnStringsSetup))] public static void RunAllTestsForSingleServer_TCP() { @@ -106,17 +106,17 @@ static async Task LocalCopyTo(Stream source, Stream destination, int bufferSize, int sharedLength = Math.Min(inputData.Length, outputData.Length); if (sharedLength < outputData.Length) { - Assert.False(true, $"output is longer than input, input={inputData.Length} bytes, output={outputData.Length} bytes"); + Assert.Fail($"output is longer than input, input={inputData.Length} bytes, output={outputData.Length} bytes"); } if (sharedLength < inputData.Length) { - Assert.False(true, $"input is longer than output, input={inputData.Length} bytes, output={outputData.Length} bytes"); + Assert.Fail($"input is longer than output, input={inputData.Length} bytes, output={outputData.Length} bytes"); } for (int index = 0; index < sharedLength; index++) { if (inputData[index] != outputData[index]) // avoid formatting the output string unless there is a difference { - Assert.True(false, $"input and output differ at index {index}, input={inputData[index]}, output={outputData[index]}"); + Assert.Fail($"input and output differ at index {index}, input={inputData[index]}, output={outputData[index]}"); } } diff --git a/src/Microsoft.Data.SqlClient/tests/ManualTests/SQL/ExceptionTest/ConnectionExceptionTest.cs b/src/Microsoft.Data.SqlClient/tests/ManualTests/SQL/ExceptionTest/ConnectionExceptionTest.cs index 86e287651f..9b8e7476e4 100644 --- a/src/Microsoft.Data.SqlClient/tests/ManualTests/SQL/ExceptionTest/ConnectionExceptionTest.cs +++ b/src/Microsoft.Data.SqlClient/tests/ManualTests/SQL/ExceptionTest/ConnectionExceptionTest.cs @@ -176,8 +176,7 @@ public void NamedPipeInvalidConnStringTest() OpenBadConnection(builder.ConnectionString, invalidConnStringError); } - [Fact] - [SkipOnTargetFramework(~TargetFrameworkMonikers.Uap)] + [ConditionalFact(typeof(DataTestUtility), nameof(DataTestUtility.IsRunningAsUWPApp))] public static void LocalDBNotSupportedOnUapTest() { SqlConnectionStringBuilder builder = new SqlConnectionStringBuilder(@$"server=(localdb)\{DataTestUtility.LocalDbAppName}") @@ -195,6 +194,7 @@ public static void LocalDBNotSupportedOnUapTest() }); } + private void GenerateConnectionException(string connectionString) { using (SqlConnection sqlConnection = new SqlConnection(connectionString)) diff --git a/src/Microsoft.Data.SqlClient/tests/ManualTests/SQL/IntegratedAuthenticationTest/IntegratedAuthenticationTest.cs b/src/Microsoft.Data.SqlClient/tests/ManualTests/SQL/IntegratedAuthenticationTest/IntegratedAuthenticationTest.cs index 654d020742..e043b2253c 100644 --- a/src/Microsoft.Data.SqlClient/tests/ManualTests/SQL/IntegratedAuthenticationTest/IntegratedAuthenticationTest.cs +++ b/src/Microsoft.Data.SqlClient/tests/ManualTests/SQL/IntegratedAuthenticationTest/IntegratedAuthenticationTest.cs @@ -30,7 +30,7 @@ public static void IntegratedAuthenticationTestWithOutConnectionPooling() TryOpenConnectionWithIntegratedAuthentication(builder.ConnectionString); } - [ActiveIssue(21707)] + [ActiveIssue("21707")] [ConditionalFact(nameof(IsIntegratedSecurityEnvironmentSet), nameof(AreConnectionStringsSetup))] public static void IntegratedAuthenticationTest_InvalidServerSPN() { diff --git a/src/Microsoft.Data.SqlClient/tests/ManualTests/SQL/LocalDBTest/LocalDBTest.cs b/src/Microsoft.Data.SqlClient/tests/ManualTests/SQL/LocalDBTest/LocalDBTest.cs index 9b8284dcac..29ff71270c 100644 --- a/src/Microsoft.Data.SqlClient/tests/ManualTests/SQL/LocalDBTest/LocalDBTest.cs +++ b/src/Microsoft.Data.SqlClient/tests/ManualTests/SQL/LocalDBTest/LocalDBTest.cs @@ -26,15 +26,15 @@ private enum InfoType private static readonly string s_startLocalDbCommand = @$"/c SqlLocalDb start {DataTestUtility.LocalDbAppName}"; private static readonly string s_localDbNamedPipeConnectionString = @$"server={GetLocalDbNamedPipe()}"; + #region LocalDbTests - [SkipOnTargetFramework(TargetFrameworkMonikers.Uap)] // No Registry support on UAP + [ConditionalFact(nameof(IsLocalDBEnvironmentSet))] public static void SqlLocalDbConnectionTest() { ConnectionTest(s_localDbConnectionString); } - [SkipOnTargetFramework(TargetFrameworkMonikers.Uap)] // No Registry support on UAP [ConditionalFact(nameof(IsLocalDBEnvironmentSet))] public static void LocalDBEncryptionNotSupportedTest() { @@ -43,7 +43,6 @@ public static void LocalDBEncryptionNotSupportedTest() ConnectionWithEncryptionTest(s_localDbConnectionString); } - [SkipOnTargetFramework(TargetFrameworkMonikers.Uap)] // No Registry support on UAP [ConditionalFact(nameof(IsLocalDBEnvironmentSet))] public static void LocalDBMarsTest() { @@ -51,17 +50,15 @@ public static void LocalDBMarsTest() ConnectionWithMarsTest(s_localDbConnectionString); } - [SkipOnTargetFramework(TargetFrameworkMonikers.Uap)] // No Registry support on UAP [ConditionalFact(nameof(IsLocalDBEnvironmentSet))] public static void InvalidLocalDBTest() { using var connection = new SqlConnection(s_badConnectionString); DataTestUtility.AssertThrowsWrapper(() => connection.Open()); } - #endregion +#endregion #region SharedLocalDb tests - [SkipOnTargetFramework(TargetFrameworkMonikers.Uap)] // No Registry support on UAP [ConditionalFact(nameof(IsLocalDbSharedInstanceSet))] public static void SharedLocalDbEncryptionTest() { @@ -73,7 +70,6 @@ public static void SharedLocalDbEncryptionTest() } } - [SkipOnTargetFramework(TargetFrameworkMonikers.Uap)] // No Registry support on UAP [ConditionalFact(nameof(IsLocalDbSharedInstanceSet))] public static void SharedLocalDbMarsTest() { @@ -83,7 +79,6 @@ public static void SharedLocalDbMarsTest() } } - [SkipOnTargetFramework(TargetFrameworkMonikers.Uap)] // No Registry support on UAP [ConditionalFact(nameof(IsLocalDbSharedInstanceSet))] public static void SqlLocalDbSharedInstanceConnectionTest() { @@ -94,19 +89,18 @@ public static void SqlLocalDbSharedInstanceConnectionTest() } #endregion + #region NamedPipeTests [Fact] - [SkipOnTargetFramework(TargetFrameworkMonikers.Uap)] // No Registry support on UAP - [ActiveIssue(20245)] //pending pipeline configuration + [ActiveIssue("20245")] //pending pipeline configuration public static void SqlLocalDbNamedPipeConnectionTest() { ConnectionTest(s_localDbNamedPipeConnectionString); } [Fact] - [SkipOnTargetFramework(TargetFrameworkMonikers.Uap)] // No Registry support on UAP - [ActiveIssue(20245)] //pending pipeline configuration + [ActiveIssue("20245")] //pending pipeline configuration public static void LocalDBNamedPipeEncryptionNotSupportedTest() { // Encryption is not supported by SQL Local DB. @@ -115,8 +109,7 @@ public static void LocalDBNamedPipeEncryptionNotSupportedTest() } [Fact] - [SkipOnTargetFramework(TargetFrameworkMonikers.Uap)] // No Registry support on UAP - [ActiveIssue(20245)] //pending pipeline configuration + [ActiveIssue("20245")] //pending pipeline configuration public static void LocalDBNamepipeMarsTest() { ConnectionWithMarsTest(s_localDbNamedPipeConnectionString); @@ -126,7 +119,6 @@ public static void LocalDBNamepipeMarsTest() #region Failures // ToDo: After adding shared memory support on managed SNI, the IsNativeSNI could be taken out - [SkipOnTargetFramework(TargetFrameworkMonikers.Uap)] // No Registry support on UAP [ConditionalTheory(nameof(IsLocalDBEnvironmentSet), nameof(IsNativeSNI))] [InlineData("lpc:")] public static void SharedMemoryAndSqlLocalDbConnectionTest(string prefix) @@ -137,7 +129,6 @@ public static void SharedMemoryAndSqlLocalDbConnectionTest(string prefix) Assert.Contains("A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: SQL Network Interfaces, error: 41 - Cannot open a Shared Memory connection to a remote SQL server)", ex.Message); } - [SkipOnTargetFramework(TargetFrameworkMonikers.Uap)] // No Registry support on UAP [InlineData("tcp:")] [InlineData("np:")] [InlineData("undefinded:")] @@ -150,7 +141,6 @@ public static void PrefixAndSqlLocalDbConnectionTest(string prefix) Assert.Contains("A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: SQL Network Interfaces, error: 26 - Error Locating Server/Instance Specified)", ex.Message); } - [SkipOnTargetFramework(TargetFrameworkMonikers.Uap)] // No Registry support on UAP [ConditionalFact(nameof(IsLocalDBEnvironmentSet)/*, nameof(IsNativeSNI)*/)] public static void InvalidSqlLocalDbConnectionTest() { diff --git a/src/Microsoft.Data.SqlClient/tests/ManualTests/SQL/MARSSessionPoolingTest/MARSSessionPoolingTest.cs b/src/Microsoft.Data.SqlClient/tests/ManualTests/SQL/MARSSessionPoolingTest/MARSSessionPoolingTest.cs index b205ee0af2..4de06aeda3 100644 --- a/src/Microsoft.Data.SqlClient/tests/ManualTests/SQL/MARSSessionPoolingTest/MARSSessionPoolingTest.cs +++ b/src/Microsoft.Data.SqlClient/tests/ManualTests/SQL/MARSSessionPoolingTest/MARSSessionPoolingTest.cs @@ -67,7 +67,7 @@ public static void MarsExecuteReader_RPC_NoGC() } // Synapse: Catalog view 'dm_exec_connections' is not supported in this version. - [ActiveIssue(11167)] + [ActiveIssue("11167")] [ConditionalFact(typeof(DataTestUtility), nameof(DataTestUtility.AreConnStringsSetup), nameof(DataTestUtility.IsNotAzureSynapse))] public static void MarsExecuteReader_Text_WithGC() { @@ -76,7 +76,7 @@ public static void MarsExecuteReader_Text_WithGC() } // Synapse: Stored procedure sp_who does not exist or is not supported. - [ActiveIssue(8959)] + [ActiveIssue("8959")] [ConditionalFact(typeof(DataTestUtility), nameof(DataTestUtility.AreConnStringsSetup), nameof(DataTestUtility.IsNotAzureSynapse))] public static void MarsExecuteReader_StoredProcedure_WithGC() { diff --git a/src/Microsoft.Data.SqlClient/tests/ManualTests/SQL/MARSTest/MARSTest.cs b/src/Microsoft.Data.SqlClient/tests/ManualTests/SQL/MARSTest/MARSTest.cs index 7a04564346..2cdbfdcc40 100644 --- a/src/Microsoft.Data.SqlClient/tests/ManualTests/SQL/MARSTest/MARSTest.cs +++ b/src/Microsoft.Data.SqlClient/tests/ManualTests/SQL/MARSTest/MARSTest.cs @@ -688,7 +688,7 @@ FROM [{table}] AS [l] } catch (Exception e) { - Assert.False(true, "CRITIAL: Test should not fail randomly. Exception occurred: " + e.Message); + Assert.Fail("CRITIAL: Test should not fail randomly. Exception occurred: " + e.Message); } finally { diff --git a/src/Microsoft.Data.SqlClient/tests/ManualTests/SQL/ParameterTest/ParametersTest.cs b/src/Microsoft.Data.SqlClient/tests/ManualTests/SQL/ParameterTest/ParametersTest.cs index 93f31bf9f1..3b71cbf851 100644 --- a/src/Microsoft.Data.SqlClient/tests/ManualTests/SQL/ParameterTest/ParametersTest.cs +++ b/src/Microsoft.Data.SqlClient/tests/ManualTests/SQL/ParameterTest/ParametersTest.cs @@ -761,7 +761,7 @@ public static void ClosedConnection_SqlParameterValueTest() } catch (Exception e) { - Assert.False(true, $"Unexpected exception occurred: {e.Message}"); + Assert.Fail($"Unexpected exception occurred: {e.Message}"); } } }); @@ -804,7 +804,7 @@ private static void RunParameterTest() return; else if ((Guid)cm.Parameters["@id2"].Value != expectedGuid) { - Assert.False(true, "CRITICAL : Unexpected data found in SqlCommand parameters, this is a MAJOR issue."); + Assert.Fail("CRITICAL : Unexpected data found in SqlCommand parameters, this is a MAJOR issue."); } } } diff --git a/src/Microsoft.Data.SqlClient/tests/ManualTests/SQL/ParameterTest/TvpTest.cs b/src/Microsoft.Data.SqlClient/tests/ManualTests/SQL/ParameterTest/TvpTest.cs index 7a13fdceb5..b8882b451a 100644 --- a/src/Microsoft.Data.SqlClient/tests/ManualTests/SQL/ParameterTest/TvpTest.cs +++ b/src/Microsoft.Data.SqlClient/tests/ManualTests/SQL/ParameterTest/TvpTest.cs @@ -53,7 +53,7 @@ public void TestMain() } [ConditionalFact(typeof(DataTestUtility), nameof(DataTestUtility.AreConnStringsSetup), nameof(DataTestUtility.IsNotAzureServer))] - [ActiveIssue(5531)] + [ActiveIssue("5531")] public void TestPacketNumberWraparound() { // this test uses a specifically crafted sql record enumerator and data to put the TdsParserStateObject.WritePacket(byte,bool) @@ -120,7 +120,7 @@ public void TestConnectionIsSafeToReuse() cmd.CommandTimeout = 100; AddCommandParameters(cmd, parameters); new SqlDataAdapter(cmd).Fill(new("BadFunc")); - Assert.False(true, "Expected exception did not occur"); + Assert.Fail("Expected exception did not occur"); } catch (Exception e) { @@ -140,7 +140,7 @@ public void TestConnectionIsSafeToReuse() } catch (Exception e) { - Assert.False(true, $"Unexpected error occurred: {e.Message}"); + Assert.Fail($"Unexpected error occurred: {e.Message}"); } } diff --git a/src/Microsoft.Data.SqlClient/tests/ManualTests/SQL/RetryLogic/RetryLogicCounterTest.cs b/src/Microsoft.Data.SqlClient/tests/ManualTests/SQL/RetryLogic/RetryLogicCounterTest.cs index b62f2f1f53..e451091315 100644 --- a/src/Microsoft.Data.SqlClient/tests/ManualTests/SQL/RetryLogic/RetryLogicCounterTest.cs +++ b/src/Microsoft.Data.SqlClient/tests/ManualTests/SQL/RetryLogic/RetryLogicCounterTest.cs @@ -53,7 +53,7 @@ public async void ValidateRetryCount_SqlCommand_Async(string methodName, int num default: break; } - Assert.False(true, "Exception did not occur."); + Assert.Fail("Exception did not occur."); } catch { @@ -103,7 +103,7 @@ public void ValidateRetryCount_SqlCommand_Sync(string methodName, int numOfTries default: break; } - Assert.False(true, "Exception did not occur."); + Assert.Fail("Exception did not occur."); } catch { diff --git a/src/Microsoft.Data.SqlClient/tests/ManualTests/SQL/RetryLogic/SqlCommandReliabilityTest.cs b/src/Microsoft.Data.SqlClient/tests/ManualTests/SQL/RetryLogic/SqlCommandReliabilityTest.cs index 9e3ed81af4..60c737e530 100644 --- a/src/Microsoft.Data.SqlClient/tests/ManualTests/SQL/RetryLogic/SqlCommandReliabilityTest.cs +++ b/src/Microsoft.Data.SqlClient/tests/ManualTests/SQL/RetryLogic/SqlCommandReliabilityTest.cs @@ -107,7 +107,7 @@ public void RetryExecuteCancel(string cnnString, SqlRetryLogicBaseProvider provi } } - [ActiveIssue(14588)] + [ActiveIssue("14588")] [ConditionalTheory(typeof(DataTestUtility), nameof(DataTestUtility.IsNotAzureSynapse), nameof(DataTestUtility.AreConnStringsSetup))] [MemberData(nameof(RetryLogicTestHelper.GetConnectionAndRetryStrategyInvalidCommand), parameters: new object[] { 5 }, MemberType = typeof(RetryLogicTestHelper), DisableDiscoveryEnumeration = true)] public void RetryExecuteWithTransScope(string cnnString, SqlRetryLogicBaseProvider provider) @@ -233,7 +233,7 @@ public void RetryExecuteUnauthorizedSqlStatementDML(string cnnString, SqlRetryLo } } - [ActiveIssue(14325)] + [ActiveIssue("14325")] // avoid creating a new database in Azure [ConditionalTheory(typeof(DataTestUtility), nameof(DataTestUtility.IsNotAzureServer), nameof(DataTestUtility.IsNotAzureSynapse), nameof(DataTestUtility.AreConnStringsSetup))] [MemberData(nameof(RetryLogicTestHelper.GetConnectionAndRetryStrategyDropDB), parameters: new object[] { 5 }, MemberType = typeof(RetryLogicTestHelper), DisableDiscoveryEnumeration = true)] diff --git a/src/Microsoft.Data.SqlClient/tests/ManualTests/SQL/RetryLogic/SqlConnectionReliabilityTest.cs b/src/Microsoft.Data.SqlClient/tests/ManualTests/SQL/RetryLogic/SqlConnectionReliabilityTest.cs index 2c42f456c9..0d7cba84c5 100644 --- a/src/Microsoft.Data.SqlClient/tests/ManualTests/SQL/RetryLogic/SqlConnectionReliabilityTest.cs +++ b/src/Microsoft.Data.SqlClient/tests/ManualTests/SQL/RetryLogic/SqlConnectionReliabilityTest.cs @@ -49,7 +49,7 @@ public void ConnectionCancelRetryOpenInvalidCatalog(string cnnString, SqlRetryLo } } - [ActiveIssue(14590, TestPlatforms.Windows)] + [ActiveIssue("14590", TestPlatforms.Windows)] // avoid creating a new database in Azure [ConditionalTheory(typeof(DataTestUtility), nameof(DataTestUtility.IsNotAzureServer), nameof(DataTestUtility.IsNotAzureSynapse), nameof(DataTestUtility.AreConnStringsSetup))] [MemberData(nameof(RetryLogicTestHelper.GetConnectionAndRetryStrategyLongRunner), parameters: new object[] { 10 }, MemberType = typeof(RetryLogicTestHelper), DisableDiscoveryEnumeration = true)] @@ -98,7 +98,7 @@ public void CreateDatabaseWhileTryingToConnect(string cnnString, SqlRetryLogicBa Assert.True(currentRetries > 0); } - [ActiveIssue(25147)] + [ActiveIssue("25147")] [ConditionalTheory(typeof(DataTestUtility), nameof(DataTestUtility.AreConnStringsSetup))] [MemberData(nameof(RetryLogicTestHelper.GetConnectionAndRetryStrategyInvalidCatalog), parameters: new object[] { 2 }, MemberType = typeof(RetryLogicTestHelper), DisableDiscoveryEnumeration = true)] public void ConcurrentExecution(string cnnString, SqlRetryLogicBaseProvider provider) diff --git a/src/Microsoft.Data.SqlClient/tests/ManualTests/SQL/SplitPacketTest/SplitPacketTest.cs b/src/Microsoft.Data.SqlClient/tests/ManualTests/SQL/SplitPacketTest/SplitPacketTest.cs index 4d4313a000..1147e704ca 100644 --- a/src/Microsoft.Data.SqlClient/tests/ManualTests/SQL/SplitPacketTest/SplitPacketTest.cs +++ b/src/Microsoft.Data.SqlClient/tests/ManualTests/SQL/SplitPacketTest/SplitPacketTest.cs @@ -11,7 +11,7 @@ namespace Microsoft.Data.SqlClient.ManualTesting.Tests { - [ActiveIssue(5538)] // Only testable on localhost + [ActiveIssue("5538")] // Only testable on localhost public class SplitPacketTest { private int Port = -1; diff --git a/src/Microsoft.Data.SqlClient/tests/ManualTests/SQL/SqlBulkCopyTest/SqlBulkCopyTest.cs b/src/Microsoft.Data.SqlClient/tests/ManualTests/SQL/SqlBulkCopyTest/SqlBulkCopyTest.cs index e720ff96f1..f7cb3e7490 100644 --- a/src/Microsoft.Data.SqlClient/tests/ManualTests/SQL/SqlBulkCopyTest/SqlBulkCopyTest.cs +++ b/src/Microsoft.Data.SqlClient/tests/ManualTests/SQL/SqlBulkCopyTest/SqlBulkCopyTest.cs @@ -297,7 +297,7 @@ public void OrderHintTransactionTest() } [ConditionalFact(typeof(DataTestUtility), nameof(DataTestUtility.AreConnStringsSetup))] - [ActiveIssue(12219)] + [ActiveIssue("12219")] public void OrderHintIdentityColumnTest() { OrderHintIdentityColumn.Test(_connStr, AddGuid("SqlBulkCopyTest_OrderHintIdentityColumn")); 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 601bffa42a..0928a71569 100644 --- a/src/Microsoft.Data.SqlClient/tests/ManualTests/SQL/SqlCommand/SqlCommandCancelTest.cs +++ b/src/Microsoft.Data.SqlClient/tests/ManualTests/SQL/SqlCommand/SqlCommandCancelTest.cs @@ -157,7 +157,7 @@ public static void TimeoutCancel() TimeoutCancel(tcp_connStr); } - [ActiveIssue(12167)] + [ActiveIssue("12167")] [ConditionalFact(typeof(DataTestUtility), nameof(DataTestUtility.AreConnStringsSetup), nameof(DataTestUtility.IsNotAzureServer))] [PlatformSpecific(TestPlatforms.Windows)] public static void TimeoutCancelNP() @@ -178,14 +178,14 @@ public static void CancelAndDisposePreparedCommandNP() CancelAndDisposePreparedCommand(np_connStr); } - [ActiveIssue(5541)] + [ActiveIssue("5541")] [ConditionalFact(typeof(DataTestUtility), nameof(DataTestUtility.AreConnStringsSetup))] public static void TimeOutDuringRead() { TimeOutDuringRead(tcp_connStr); } - [ActiveIssue(5541)] + [ActiveIssue("5541")] [ConditionalFact(typeof(DataTestUtility), nameof(DataTestUtility.AreConnStringsSetup), nameof(DataTestUtility.IsNotAzureServer))] [PlatformSpecific(TestPlatforms.Windows)] public static void TimeOutDuringReadNP() @@ -306,7 +306,7 @@ IF EXISTS (SELECT name FROM msdb.dbo.sysalerts WHERE name = N'{alertName}') { if (retryAttempt >= 3 || e.Message.Contains("The transaction operation cannot be performed")) { - Assert.False(true, $"Retry Attempt: {retryAttempt} | Unexpected Exception occurred: {e.Message}"); + Assert.Fail($"Retry Attempt: {retryAttempt} | Unexpected Exception occurred: {e.Message}"); } else { diff --git a/src/Microsoft.Data.SqlClient/tests/ManualTests/SQL/SqlDependencyTest/SqlDependencyTest.cs b/src/Microsoft.Data.SqlClient/tests/ManualTests/SQL/SqlDependencyTest/SqlDependencyTest.cs index 38cd77a89e..c2a4ab79e8 100644 --- a/src/Microsoft.Data.SqlClient/tests/ManualTests/SQL/SqlDependencyTest/SqlDependencyTest.cs +++ b/src/Microsoft.Data.SqlClient/tests/ManualTests/SQL/SqlDependencyTest/SqlDependencyTest.cs @@ -122,7 +122,7 @@ public void SqlDependencyStartStopTest() } catch (Exception e) { - Assert.True(false, e.Message); + Assert.Fail(e.Message); } } @@ -152,7 +152,7 @@ public void SqlDependencyStartStopDefaultTest() } catch (Exception e) { - Assert.True(false, e.Message); + Assert.Fail(e.Message); } } diff --git a/src/Microsoft.Data.SqlClient/tests/ManualTests/SQL/SqlNotificationTest/SqlNotificationTest.cs b/src/Microsoft.Data.SqlClient/tests/ManualTests/SQL/SqlNotificationTest/SqlNotificationTest.cs index 11827aa15f..ed7c5b5b8a 100644 --- a/src/Microsoft.Data.SqlClient/tests/ManualTests/SQL/SqlNotificationTest/SqlNotificationTest.cs +++ b/src/Microsoft.Data.SqlClient/tests/ManualTests/SQL/SqlNotificationTest/SqlNotificationTest.cs @@ -226,7 +226,7 @@ public void Test_SingleDependency_CustomQueue_SqlAuth() /// /// SqlDependecy premature timeout /// - [ActiveIssue(5539)] + [ActiveIssue("5539")] [ConditionalFact(typeof(DataTestUtility), nameof(DataTestUtility.AreConnStringsSetup))] public void Test_SingleDependency_Timeout() { diff --git a/src/Microsoft.Data.SqlClient/tests/ManualTests/SQL/TransactionTest/DistributedTransactionTest.cs b/src/Microsoft.Data.SqlClient/tests/ManualTests/SQL/TransactionTest/DistributedTransactionTest.cs index 93f57957ec..dc04ea56ae 100644 --- a/src/Microsoft.Data.SqlClient/tests/ManualTests/SQL/TransactionTest/DistributedTransactionTest.cs +++ b/src/Microsoft.Data.SqlClient/tests/ManualTests/SQL/TransactionTest/DistributedTransactionTest.cs @@ -3,6 +3,7 @@ // See the LICENSE file in the project root for more information. using System; +using System.Runtime.InteropServices; using System.Threading.Tasks; using System.Transactions; using Xunit; @@ -14,7 +15,7 @@ namespace Microsoft.Data.SqlClient.ManualTesting.Tests [PlatformSpecific(TestPlatforms.Windows)] public class DistributedTransactionTest { - private static bool s_DelegatedTransactionCondition => DataTestUtility.AreConnStringsSetup() && DataTestUtility.IsNotAzureServer() && PlatformDetection.IsNotX86Process; + private static bool s_DelegatedTransactionCondition => DataTestUtility.AreConnStringsSetup() && DataTestUtility.IsNotAzureServer() && DataTestUtility.IsNotX86Architecture; [ConditionalFact(nameof(s_DelegatedTransactionCondition), Timeout = 10000)] public async Task Delegated_transaction_deadlock_in_SinglePhaseCommit() 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 31151857c0..bdbd805e73 100644 --- a/src/Microsoft.Data.SqlClient/tests/ManualTests/SQL/UdtTest/SqlServerTypesTest.cs +++ b/src/Microsoft.Data.SqlClient/tests/ManualTests/SQL/UdtTest/SqlServerTypesTest.cs @@ -252,7 +252,7 @@ private static void TestUdtSqlDataReaderGetStream(CommandBehavior behavior) } // Synapse: Parse error at line: 1, column: 41: Incorrect syntax near 'hierarchyid'. - [ActiveIssue(25421, TargetFrameworkMonikers.NetFramework)] + [ActiveIssue("25421", TargetFrameworkMonikers.NetFramework)] [ConditionalFact(typeof(DataTestUtility), nameof(DataTestUtility.AreConnStringsSetup), nameof(DataTestUtility.IsNotAzureSynapse))] public static void TestUdtSchemaMetadata() { diff --git a/src/Microsoft.Data.SqlClient/tests/ManualTests/SQL/UdtTest/UdtBulkCopyTest.cs b/src/Microsoft.Data.SqlClient/tests/ManualTests/SQL/UdtTest/UdtBulkCopyTest.cs index 90ceed4952..8adf6c7bb5 100644 --- a/src/Microsoft.Data.SqlClient/tests/ManualTests/SQL/UdtTest/UdtBulkCopyTest.cs +++ b/src/Microsoft.Data.SqlClient/tests/ManualTests/SQL/UdtTest/UdtBulkCopyTest.cs @@ -11,7 +11,7 @@ public class UdtBulkCopyTest { private string _connStr; - [ActiveIssue(5535)] + [ActiveIssue("5535")] [ConditionalFact(typeof(DataTestUtility), nameof(DataTestUtility.IsUdtTestDatabasePresent), nameof(DataTestUtility.AreConnStringsSetup))] public void RunCopyTest() { diff --git a/src/Microsoft.Data.SqlClient/tests/ManualTests/SQL/UdtTest/UdtTest2.cs b/src/Microsoft.Data.SqlClient/tests/ManualTests/SQL/UdtTest/UdtTest2.cs index 952c49c291..16d48d7c37 100644 --- a/src/Microsoft.Data.SqlClient/tests/ManualTests/SQL/UdtTest/UdtTest2.cs +++ b/src/Microsoft.Data.SqlClient/tests/ManualTests/SQL/UdtTest/UdtTest2.cs @@ -11,7 +11,7 @@ namespace Microsoft.Data.SqlClient.ManualTesting.Tests { - [ActiveIssue(5536)] + [ActiveIssue("5536")] // TODO Synapse: Remove dependency from UDTTest Database public class UdtTest2 { diff --git a/src/Microsoft.Data.SqlClient/tests/ManualTests/SQL/WeakRefTestYukonSpecific/WeakRefTestYukonSpecific.cs b/src/Microsoft.Data.SqlClient/tests/ManualTests/SQL/WeakRefTestYukonSpecific/WeakRefTestYukonSpecific.cs index 5835bb9e69..bf0567df82 100644 --- a/src/Microsoft.Data.SqlClient/tests/ManualTests/SQL/WeakRefTestYukonSpecific/WeakRefTestYukonSpecific.cs +++ b/src/Microsoft.Data.SqlClient/tests/ManualTests/SQL/WeakRefTestYukonSpecific/WeakRefTestYukonSpecific.cs @@ -17,7 +17,7 @@ public static class WeakRefTestYukonSpecific private const int CONCURRENT_COMMANDS = 5; // TODO Synapse: Remove dependency on Northwind database - [ActiveIssue(6643, TestPlatforms.AnyUnix)] + [ActiveIssue("6643", TestPlatforms.AnyUnix)] [ConditionalFact(typeof(DataTestUtility), nameof(DataTestUtility.AreConnStringsSetup), nameof(DataTestUtility.IsNotAzureSynapse))] public static void TestReaderMars() { diff --git a/src/Microsoft.Data.SqlClient/tests/tools/Microsoft.Data.SqlClient.TestUtilities/xunit.runner.json b/src/Microsoft.Data.SqlClient/tests/tools/Microsoft.Data.SqlClient.TestUtilities/xunit.runner.json new file mode 100644 index 0000000000..8faf1479cc --- /dev/null +++ b/src/Microsoft.Data.SqlClient/tests/tools/Microsoft.Data.SqlClient.TestUtilities/xunit.runner.json @@ -0,0 +1,6 @@ +{ + "$schema": "https://xunit.net/schema/current/xunit.runner.schema.json", + "diagnosticMessages": true, + "parallelizeAssembly": true, + "shadowCopy": false +} diff --git a/src/Microsoft.Data.SqlClient/tests/tools/Microsoft.DotNet.XUnitExtensions/Attributes/ActiveIssueAttribute.cs b/src/Microsoft.Data.SqlClient/tests/tools/Microsoft.DotNet.XUnitExtensions/Attributes/ActiveIssueAttribute.cs deleted file mode 100644 index 97c9e4b521..0000000000 --- a/src/Microsoft.Data.SqlClient/tests/tools/Microsoft.DotNet.XUnitExtensions/Attributes/ActiveIssueAttribute.cs +++ /dev/null @@ -1,24 +0,0 @@ -// 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 Xunit.Sdk; - -namespace Xunit -{ - /// - /// Apply this attribute to your test method to specify an active issue. - /// - [TraitDiscoverer("Microsoft.DotNet.XUnitExtensions.ActiveIssueDiscoverer", "Microsoft.DotNet.XUnitExtensions")] - [AttributeUsage(AttributeTargets.Method | AttributeTargets.Class, AllowMultiple = true)] - public class ActiveIssueAttribute : Attribute, ITraitAttribute - { - public ActiveIssueAttribute(int issueNumber, TestPlatforms platforms) { } - public ActiveIssueAttribute(string issue, TestPlatforms platforms) { } - public ActiveIssueAttribute(int issueNumber, TargetFrameworkMonikers framework) { } - public ActiveIssueAttribute(string issue, TargetFrameworkMonikers framework) { } - public ActiveIssueAttribute(int issueNumber, TestPlatforms platforms = TestPlatforms.Any, TargetFrameworkMonikers framework = (TargetFrameworkMonikers)0) { } - public ActiveIssueAttribute(string issue, TestPlatforms platforms = TestPlatforms.Any, TargetFrameworkMonikers framework = (TargetFrameworkMonikers)0) { } - } -} diff --git a/src/Microsoft.Data.SqlClient/tests/tools/Microsoft.DotNet.XUnitExtensions/Attributes/ConditionalClassAttribute.cs b/src/Microsoft.Data.SqlClient/tests/tools/Microsoft.DotNet.XUnitExtensions/Attributes/ConditionalClassAttribute.cs deleted file mode 100644 index 6ca0fc3bf0..0000000000 --- a/src/Microsoft.Data.SqlClient/tests/tools/Microsoft.DotNet.XUnitExtensions/Attributes/ConditionalClassAttribute.cs +++ /dev/null @@ -1,23 +0,0 @@ -// 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 Xunit.Sdk; - -namespace Xunit -{ - [TraitDiscoverer("Microsoft.DotNet.XUnitExtensions.ConditionalClassDiscoverer", "Microsoft.DotNet.XUnitExtensions")] - [AttributeUsage(AttributeTargets.Class, AllowMultiple = false)] - public sealed class ConditionalClassAttribute : Attribute, ITraitAttribute - { - public Type CalleeType { get; private set; } - public string[] ConditionMemberNames { get; private set; } - - public ConditionalClassAttribute(Type calleeType, params string[] conditionMemberNames) - { - CalleeType = calleeType; - ConditionMemberNames = conditionMemberNames; - } - } -} diff --git a/src/Microsoft.Data.SqlClient/tests/tools/Microsoft.DotNet.XUnitExtensions/Attributes/ConditionalFactAttribute.cs b/src/Microsoft.Data.SqlClient/tests/tools/Microsoft.DotNet.XUnitExtensions/Attributes/ConditionalFactAttribute.cs deleted file mode 100644 index 54996c0449..0000000000 --- a/src/Microsoft.Data.SqlClient/tests/tools/Microsoft.DotNet.XUnitExtensions/Attributes/ConditionalFactAttribute.cs +++ /dev/null @@ -1,28 +0,0 @@ -// 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 Xunit.Sdk; - -namespace Xunit -{ - [XunitTestCaseDiscoverer("Microsoft.DotNet.XUnitExtensions.ConditionalFactDiscoverer", "Microsoft.DotNet.XUnitExtensions")] - [AttributeUsage(AttributeTargets.Method, AllowMultiple = false)] - public sealed class ConditionalFactAttribute : FactAttribute - { - public Type CalleeType { get; private set; } - public string[] ConditionMemberNames { get; private set; } - - public ConditionalFactAttribute(Type calleeType, params string[] conditionMemberNames) - { - CalleeType = calleeType; - ConditionMemberNames = conditionMemberNames; - } - - public ConditionalFactAttribute(params string[] conditionMemberNames) - { - ConditionMemberNames = conditionMemberNames; - } - } -} diff --git a/src/Microsoft.Data.SqlClient/tests/tools/Microsoft.DotNet.XUnitExtensions/Attributes/ConditionalTheoryAttribute.cs b/src/Microsoft.Data.SqlClient/tests/tools/Microsoft.DotNet.XUnitExtensions/Attributes/ConditionalTheoryAttribute.cs deleted file mode 100644 index f924102cab..0000000000 --- a/src/Microsoft.Data.SqlClient/tests/tools/Microsoft.DotNet.XUnitExtensions/Attributes/ConditionalTheoryAttribute.cs +++ /dev/null @@ -1,28 +0,0 @@ -// 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 Xunit.Sdk; - -namespace Xunit -{ - [XunitTestCaseDiscoverer("Microsoft.DotNet.XUnitExtensions.ConditionalTheoryDiscoverer", "Microsoft.DotNet.XUnitExtensions")] - [AttributeUsage(AttributeTargets.Method, AllowMultiple = false)] - public sealed class ConditionalTheoryAttribute : TheoryAttribute - { - public Type CalleeType { get; private set; } - public string[] ConditionMemberNames { get; private set; } - - public ConditionalTheoryAttribute(Type calleeType, params string[] conditionMemberNames) - { - CalleeType = calleeType; - ConditionMemberNames = conditionMemberNames; - } - - public ConditionalTheoryAttribute(params string[] conditionMemberNames) - { - ConditionMemberNames = conditionMemberNames; - } - } -} diff --git a/src/Microsoft.Data.SqlClient/tests/tools/Microsoft.DotNet.XUnitExtensions/Attributes/OuterLoopAttribute.cs b/src/Microsoft.Data.SqlClient/tests/tools/Microsoft.DotNet.XUnitExtensions/Attributes/OuterLoopAttribute.cs deleted file mode 100644 index 6194eadbd6..0000000000 --- a/src/Microsoft.Data.SqlClient/tests/tools/Microsoft.DotNet.XUnitExtensions/Attributes/OuterLoopAttribute.cs +++ /dev/null @@ -1,20 +0,0 @@ -// 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 Xunit.Sdk; - -namespace Xunit -{ - /// - /// Apply this attribute to your test method to specify a outer-loop category. - /// - [TraitDiscoverer("Microsoft.DotNet.XUnitExtensions.OuterLoopTestsDiscoverer", "Microsoft.DotNet.XUnitExtensions")] - [AttributeUsage(AttributeTargets.Method | AttributeTargets.Class, AllowMultiple = true)] - public class OuterLoopAttribute : Attribute, ITraitAttribute - { - public OuterLoopAttribute() { } - public OuterLoopAttribute(string reason) { } - } -} diff --git a/src/Microsoft.Data.SqlClient/tests/tools/Microsoft.DotNet.XUnitExtensions/Attributes/PlatformSpecificAttribute.cs b/src/Microsoft.Data.SqlClient/tests/tools/Microsoft.DotNet.XUnitExtensions/Attributes/PlatformSpecificAttribute.cs deleted file mode 100644 index 0f4d6bd025..0000000000 --- a/src/Microsoft.Data.SqlClient/tests/tools/Microsoft.DotNet.XUnitExtensions/Attributes/PlatformSpecificAttribute.cs +++ /dev/null @@ -1,19 +0,0 @@ -// 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 Xunit.Sdk; - -namespace Xunit -{ - /// - /// Apply this attribute to your test method to specify this is a platform specific test. - /// - [TraitDiscoverer("Microsoft.DotNet.XUnitExtensions.PlatformSpecificDiscoverer", "Microsoft.DotNet.XUnitExtensions")] - [AttributeUsage(AttributeTargets.Method | AttributeTargets.Class, AllowMultiple = false)] - public class PlatformSpecificAttribute : Attribute, ITraitAttribute - { - public PlatformSpecificAttribute(TestPlatforms platforms) { } - } -} diff --git a/src/Microsoft.Data.SqlClient/tests/tools/Microsoft.DotNet.XUnitExtensions/Attributes/SkipOnCoreClrAttribute.cs b/src/Microsoft.Data.SqlClient/tests/tools/Microsoft.DotNet.XUnitExtensions/Attributes/SkipOnCoreClrAttribute.cs deleted file mode 100644 index abf1fda557..0000000000 --- a/src/Microsoft.Data.SqlClient/tests/tools/Microsoft.DotNet.XUnitExtensions/Attributes/SkipOnCoreClrAttribute.cs +++ /dev/null @@ -1,21 +0,0 @@ -// 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 Xunit.Sdk; - -namespace Xunit -{ - [TraitDiscoverer("Microsoft.DotNet.XUnitExtensions.SkipOnCoreClrDiscoverer", "Microsoft.DotNet.XUnitExtensions")] - [AttributeUsage(AttributeTargets.Assembly | AttributeTargets.Class | AttributeTargets.Method, AllowMultiple = false, Inherited = true)] - public class SkipOnCoreClrAttribute : Attribute, ITraitAttribute - { - internal SkipOnCoreClrAttribute() { } - - public SkipOnCoreClrAttribute(string reason, TestPlatforms testPlatforms) { } - public SkipOnCoreClrAttribute(string reason, RuntimeStressTestModes testMode) { } - public SkipOnCoreClrAttribute(string reason, TestPlatforms testPlatforms, RuntimeStressTestModes testMode) { } - public SkipOnCoreClrAttribute(string reason) { } - } -} diff --git a/src/Microsoft.Data.SqlClient/tests/tools/Microsoft.DotNet.XUnitExtensions/Attributes/SkipOnMonoAttribute.cs b/src/Microsoft.Data.SqlClient/tests/tools/Microsoft.DotNet.XUnitExtensions/Attributes/SkipOnMonoAttribute.cs deleted file mode 100644 index b535ebf1c3..0000000000 --- a/src/Microsoft.Data.SqlClient/tests/tools/Microsoft.DotNet.XUnitExtensions/Attributes/SkipOnMonoAttribute.cs +++ /dev/null @@ -1,18 +0,0 @@ -// 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 Xunit; -using Xunit.Sdk; - -namespace Microsoft.DotNet.XUnitExtensions.Attributes -{ - [TraitDiscoverer("Microsoft.DotNet.XUnitExtensions.SkipOnMonoDiscoverer", "Microsoft.DotNet.XUnitExtensions")] - [AttributeUsage(AttributeTargets.Assembly | AttributeTargets.Class | AttributeTargets.Method, AllowMultiple = false, Inherited = true)] - public class SkipOnMonoAttribute : Attribute, ITraitAttribute - { - internal SkipOnMonoAttribute() { } - public SkipOnMonoAttribute(string reason, TestPlatforms testPlatforms = TestPlatforms.Any) { } - } -} diff --git a/src/Microsoft.Data.SqlClient/tests/tools/Microsoft.DotNet.XUnitExtensions/Attributes/SkipOnTargetFrameworkAttribute.cs b/src/Microsoft.Data.SqlClient/tests/tools/Microsoft.DotNet.XUnitExtensions/Attributes/SkipOnTargetFrameworkAttribute.cs deleted file mode 100644 index 6ed78b5e0e..0000000000 --- a/src/Microsoft.Data.SqlClient/tests/tools/Microsoft.DotNet.XUnitExtensions/Attributes/SkipOnTargetFrameworkAttribute.cs +++ /dev/null @@ -1,19 +0,0 @@ -// 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 Xunit.Sdk; - -namespace Xunit -{ - /// - /// Apply this attribute to your test method to specify this is a platform specific test. - /// - [TraitDiscoverer("Microsoft.DotNet.XUnitExtensions.SkipOnTargetFrameworkDiscoverer", "Microsoft.DotNet.XUnitExtensions")] - [AttributeUsage(AttributeTargets.Method | AttributeTargets.Class, AllowMultiple = true)] - public class SkipOnTargetFrameworkAttribute : Attribute, ITraitAttribute - { - public SkipOnTargetFrameworkAttribute(TargetFrameworkMonikers platform, string reason = null) { } - } -} diff --git a/src/Microsoft.Data.SqlClient/tests/tools/Microsoft.DotNet.XUnitExtensions/Attributes/TestCategoryAttribute.cs b/src/Microsoft.Data.SqlClient/tests/tools/Microsoft.DotNet.XUnitExtensions/Attributes/TestCategoryAttribute.cs deleted file mode 100644 index 013931dc00..0000000000 --- a/src/Microsoft.Data.SqlClient/tests/tools/Microsoft.DotNet.XUnitExtensions/Attributes/TestCategoryAttribute.cs +++ /dev/null @@ -1,19 +0,0 @@ -// 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 Xunit.Sdk; - -namespace Xunit -{ - /// - /// Apply this attribute to your test method to specify the test category. - /// - [TraitDiscoverer("Microsoft.DotNet.XUnitExtensions.TestCategoryDiscoverer", "Microsoft.DotNet.XUnitExtensions")] - [AttributeUsage(AttributeTargets.Method | AttributeTargets.Class, AllowMultiple = true)] - public class TestCategoryAttribute : Attribute, ITraitAttribute - { - public TestCategoryAttribute(string category) { } - } -} diff --git a/src/Microsoft.Data.SqlClient/tests/tools/Microsoft.DotNet.XUnitExtensions/ConditionalDiscovererException.cs b/src/Microsoft.Data.SqlClient/tests/tools/Microsoft.DotNet.XUnitExtensions/ConditionalDiscovererException.cs deleted file mode 100644 index 4a7e80b6f7..0000000000 --- a/src/Microsoft.Data.SqlClient/tests/tools/Microsoft.DotNet.XUnitExtensions/ConditionalDiscovererException.cs +++ /dev/null @@ -1,13 +0,0 @@ -// 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; - -namespace Microsoft.DotNet.XUnitExtensions -{ - internal class ConditionalDiscovererException : Exception - { - public ConditionalDiscovererException(string message) : base(message) { } - } -} diff --git a/src/Microsoft.Data.SqlClient/tests/tools/Microsoft.DotNet.XUnitExtensions/DesktopTraceListener.cs b/src/Microsoft.Data.SqlClient/tests/tools/Microsoft.DotNet.XUnitExtensions/DesktopTraceListener.cs deleted file mode 100644 index 7adc2fbb53..0000000000 --- a/src/Microsoft.Data.SqlClient/tests/tools/Microsoft.DotNet.XUnitExtensions/DesktopTraceListener.cs +++ /dev/null @@ -1,32 +0,0 @@ -// 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.Diagnostics; - -namespace Microsoft.DotNet.XUnitExtensions -{ - /// - /// Trace Listener for corefx Desktop test execution to avoid showing assert pop-ups and making the test fail when an Assert fails. - /// - public class DesktopTestTraceListener : DefaultTraceListener - { - /// - /// Override of to handle Assert failures with custom behavior. - /// When an Assert failure happens during test execution we will rather throw a DebugAssertException so that the test fails and we have a full StackTrace. - /// - public override void Fail(string message, string detailMessage) - { - throw new DebugAssertException(message, detailMessage); - } - - private sealed class DebugAssertException : Exception - { - internal DebugAssertException(string message, string detailMessage) : - base(message + Environment.NewLine + detailMessage) - { - } - } - } -} diff --git a/src/Microsoft.Data.SqlClient/tests/tools/Microsoft.DotNet.XUnitExtensions/DiscovererHelpers.cs b/src/Microsoft.Data.SqlClient/tests/tools/Microsoft.DotNet.XUnitExtensions/DiscovererHelpers.cs deleted file mode 100644 index 5dab843fab..0000000000 --- a/src/Microsoft.Data.SqlClient/tests/tools/Microsoft.DotNet.XUnitExtensions/DiscovererHelpers.cs +++ /dev/null @@ -1,26 +0,0 @@ -// 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.Runtime.InteropServices; -using Xunit; - -namespace Microsoft.DotNet.XUnitExtensions -{ - internal static class DiscovererHelpers - { - internal static bool TestPlatformApplies(TestPlatforms platforms) => -#if NETCOREAPP - (platforms.HasFlag(TestPlatforms.FreeBSD) && RuntimeInformation.IsOSPlatform(OSPlatform.Create("FREEBSD"))) || - (platforms.HasFlag(TestPlatforms.Linux) && RuntimeInformation.IsOSPlatform(OSPlatform.Linux)) || - (platforms.HasFlag(TestPlatforms.NetBSD) && RuntimeInformation.IsOSPlatform(OSPlatform.Create("NETBSD"))) || - (platforms.HasFlag(TestPlatforms.OSX) && RuntimeInformation.IsOSPlatform(OSPlatform.OSX)) || - (platforms.HasFlag(TestPlatforms.Windows) && RuntimeInformation.IsOSPlatform(OSPlatform.Windows)); -# else - (platforms.HasFlag(TestPlatforms.Windows) && (int)Environment.OSVersion.Platform == 2) || - (platforms.HasFlag(TestPlatforms.Linux) && (int)Environment.OSVersion.Platform == 4) || - (platforms.HasFlag(TestPlatforms.OSX) && (int)Environment.OSVersion.Platform == 6); -#endif - } -} diff --git a/src/Microsoft.Data.SqlClient/tests/tools/Microsoft.DotNet.XUnitExtensions/Discoverers/ActiveIssueDiscoverer.cs b/src/Microsoft.Data.SqlClient/tests/tools/Microsoft.DotNet.XUnitExtensions/Discoverers/ActiveIssueDiscoverer.cs deleted file mode 100644 index 0e45c581bd..0000000000 --- a/src/Microsoft.Data.SqlClient/tests/tools/Microsoft.DotNet.XUnitExtensions/Discoverers/ActiveIssueDiscoverer.cs +++ /dev/null @@ -1,63 +0,0 @@ -// 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.Collections.Generic; -using System.Diagnostics; -using System.Linq; -using Xunit; -using Xunit.Abstractions; -using Xunit.Sdk; - -namespace Microsoft.DotNet.XUnitExtensions -{ - /// - /// This class discovers all of the tests and test classes that have - /// applied the ActiveIssue attribute - /// - public class ActiveIssueDiscoverer : ITraitDiscoverer - { - /// - /// Gets the trait values from the Category attribute. - /// - /// The trait attribute containing the trait values. - /// The trait values. - public IEnumerable> GetTraits(IAttributeInfo traitAttribute) - { - IEnumerable ctorArgs = traitAttribute.GetConstructorArguments(); - Debug.Assert(ctorArgs.Count() >= 2); - - string issue = ctorArgs.First().ToString(); - TestPlatforms platforms = TestPlatforms.Any; - TargetFrameworkMonikers frameworks = (TargetFrameworkMonikers)0; - - foreach (object arg in ctorArgs.Skip(1)) // First argument is the issue number. - { - if (arg is TestPlatforms) - { - platforms = (TestPlatforms)arg; - } - else if (arg is TargetFrameworkMonikers) - { - frameworks = (TargetFrameworkMonikers)arg; - } - } - - if (DiscovererHelpers.TestPlatformApplies(platforms)) - { - if (frameworks.HasFlag(TargetFrameworkMonikers.Netcoreapp)) - yield return new KeyValuePair(XunitConstants.Category, XunitConstants.NonNetcoreappTest); - if (frameworks.HasFlag(TargetFrameworkMonikers.NetFramework)) - yield return new KeyValuePair(XunitConstants.Category, XunitConstants.NonNetfxTest); - if (frameworks.HasFlag(TargetFrameworkMonikers.Uap)) - yield return new KeyValuePair(XunitConstants.Category, XunitConstants.NonUapTest); - if (frameworks.HasFlag(TargetFrameworkMonikers.Mono)) - yield return new KeyValuePair(XunitConstants.Category, XunitConstants.NonMonoTest); - if (frameworks == (TargetFrameworkMonikers)0) - yield return new KeyValuePair(XunitConstants.Category, XunitConstants.Failing); - - yield return new KeyValuePair(XunitConstants.ActiveIssue, issue); - } - } - } -} diff --git a/src/Microsoft.Data.SqlClient/tests/tools/Microsoft.DotNet.XUnitExtensions/Discoverers/ConditionalClassDiscoverer.cs b/src/Microsoft.Data.SqlClient/tests/tools/Microsoft.DotNet.XUnitExtensions/Discoverers/ConditionalClassDiscoverer.cs deleted file mode 100644 index 7703101313..0000000000 --- a/src/Microsoft.Data.SqlClient/tests/tools/Microsoft.DotNet.XUnitExtensions/Discoverers/ConditionalClassDiscoverer.cs +++ /dev/null @@ -1,70 +0,0 @@ -// 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.Collections.Generic; -using System.Diagnostics; -using System.Linq; -using System.Reflection; -using Xunit.Abstractions; -using Xunit.Sdk; - -namespace Microsoft.DotNet.XUnitExtensions -{ - /// - /// This class discovers all of the tests and test classes that have - /// applied the ConditionalClass attribute - /// - public class ConditionalClassDiscoverer : ITraitDiscoverer - { - /// - /// Gets the trait values from the Category attribute. - /// - /// The trait attribute containing the trait values. - /// The trait values. - public IEnumerable> GetTraits(IAttributeInfo traitAttribute) - { - // If evaluated to false, skip the test class entirely. - if (!EvaluateParameterHelper(traitAttribute)) - { - yield return new KeyValuePair(XunitConstants.Category, XunitConstants.Failing); - } - } - - internal static bool EvaluateParameterHelper(IAttributeInfo traitAttribute) - { - // Parse the traitAttribute. We make sure it contains two parts: - // 1. Type 2. nameof(conditionMemberName) - object[] conditionArguments = traitAttribute.GetConstructorArguments().ToArray(); - Debug.Assert(conditionArguments.Count() == 2); - - Type calleeType = null; - string[] conditionMemberNames = null; - - if (ConditionalTestDiscoverer.CheckInputToSkipExecution(conditionArguments, ref calleeType, ref conditionMemberNames)) - { - return true; - } - - foreach (string entry in conditionMemberNames) - { - // Null condition member names are silently tolerated. - if (string.IsNullOrWhiteSpace(entry)) - continue; - - MethodInfo conditionMethodInfo = ConditionalTestDiscoverer.LookupConditionalMethod(calleeType, entry); - if (conditionMethodInfo == null) - { - throw new InvalidOperationException($"Unable to get MethodInfo, please check input for {entry}."); - } - - // If one of the conditions is false, then return the category failing trait. - if (!(bool)conditionMethodInfo.Invoke(null, null)) - return false; - } - - return true; - } - } -} diff --git a/src/Microsoft.Data.SqlClient/tests/tools/Microsoft.DotNet.XUnitExtensions/Discoverers/ConditionalFactDiscoverer.cs b/src/Microsoft.Data.SqlClient/tests/tools/Microsoft.DotNet.XUnitExtensions/Discoverers/ConditionalFactDiscoverer.cs deleted file mode 100644 index 3b9e368ae9..0000000000 --- a/src/Microsoft.Data.SqlClient/tests/tools/Microsoft.DotNet.XUnitExtensions/Discoverers/ConditionalFactDiscoverer.cs +++ /dev/null @@ -1,27 +0,0 @@ -// 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.Linq; -using Xunit.Abstractions; -using Xunit.Sdk; - -namespace Microsoft.DotNet.XUnitExtensions -{ - public class ConditionalFactDiscoverer : FactDiscoverer - { - public ConditionalFactDiscoverer(IMessageSink diagnosticMessageSink) : base(diagnosticMessageSink) { } - - protected override IXunitTestCase CreateTestCase(ITestFrameworkDiscoveryOptions discoveryOptions, ITestMethod testMethod, IAttributeInfo factAttribute) - { - if (ConditionalTestDiscoverer.TryEvaluateSkipConditions(discoveryOptions, DiagnosticMessageSink, testMethod, factAttribute.GetConstructorArguments().ToArray(), out string skipReason, out ExecutionErrorTestCase errorTestCase)) - { - return skipReason != null - ? (IXunitTestCase)new SkippedTestCase(skipReason, DiagnosticMessageSink, discoveryOptions.MethodDisplayOrDefault(), discoveryOptions.MethodDisplayOptionsOrDefault(), testMethod) - : new SkippedFactTestCase(DiagnosticMessageSink, discoveryOptions.MethodDisplayOrDefault(), discoveryOptions.MethodDisplayOptionsOrDefault(), testMethod); // Test case skippable at runtime. - } - - return errorTestCase; - } - } -} diff --git a/src/Microsoft.Data.SqlClient/tests/tools/Microsoft.DotNet.XUnitExtensions/Discoverers/ConditionalTestDiscoverer.cs b/src/Microsoft.Data.SqlClient/tests/tools/Microsoft.DotNet.XUnitExtensions/Discoverers/ConditionalTestDiscoverer.cs deleted file mode 100644 index eac5543402..0000000000 --- a/src/Microsoft.Data.SqlClient/tests/tools/Microsoft.DotNet.XUnitExtensions/Discoverers/ConditionalTestDiscoverer.cs +++ /dev/null @@ -1,180 +0,0 @@ -// 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.Collections.Generic; -using System.Linq; -using System.Reflection; -using Xunit.Abstractions; -using Xunit.Sdk; - -namespace Microsoft.DotNet.XUnitExtensions -{ - // Internal helper class for code common to conditional test discovery through - // [ConditionalFact] and [ConditionalTheory] - internal static class ConditionalTestDiscoverer - { - // This helper method evaluates the given condition member names for a given set of test cases. - // If any condition member evaluates to 'false', the test cases are marked to be skipped. - // The skip reason is the collection of all the condition members that evaluated to 'false'. - internal static string EvaluateSkipConditions(ITestMethod testMethod, object[] conditionArguments) - { - Type calleeType = null; - string[] conditionMemberNames = null; - - if (CheckInputToSkipExecution(conditionArguments, ref calleeType, ref conditionMemberNames, testMethod)) - return null; - - MethodInfo testMethodInfo = testMethod.Method.ToRuntimeMethod(); - Type testMethodDeclaringType = testMethodInfo.DeclaringType; - List falseConditions = new List(conditionMemberNames.Count()); - - foreach (string entry in conditionMemberNames) - { - string conditionMemberName = entry; - - // Null condition member names are silently tolerated - if (string.IsNullOrWhiteSpace(conditionMemberName)) - { - continue; - } - - Type declaringType; - - if (calleeType != null) - { - declaringType = calleeType; - } - else - { - declaringType = testMethodDeclaringType; - - string[] symbols = conditionMemberName.Split('.'); - if (symbols.Length == 2) - { - conditionMemberName = symbols[1]; - ITypeInfo type = testMethod.TestClass.Class.Assembly.GetTypes(false).Where(t => t.Name.Contains(symbols[0])).FirstOrDefault(); - if (type != null) - { - declaringType = type.ToRuntimeType(); - } - } - } - - MethodInfo conditionMethodInfo; - if ((conditionMethodInfo = LookupConditionalMethod(declaringType, conditionMemberName)) == null) - { - throw new ConditionalDiscovererException(GetFailedLookupString(conditionMemberName, declaringType)); - } - - // In the case of multiple conditions, collect the results of all - // of them to produce a summary skip reason. - try - { - if (!(bool)conditionMethodInfo.Invoke(null, null)) - { - falseConditions.Add(conditionMemberName); - } - } - catch (Exception exc) - { - falseConditions.Add($"{conditionMemberName} ({exc.GetType().Name})"); - } - } - - // Compose a summary of all conditions that returned false. - if (falseConditions.Count > 0) - { - return string.Format("Condition(s) not met: \"{0}\"", string.Join("\", \"", falseConditions)); - } - - // No conditions returned false (including the absence of any conditions). - return null; - } - - internal static bool TryEvaluateSkipConditions(ITestFrameworkDiscoveryOptions discoveryOptions, IMessageSink diagnosticMessageSink, ITestMethod testMethod, object[] conditionArguments, out string skipReason, out ExecutionErrorTestCase errorTestCase) - { - skipReason = null; - errorTestCase = null; - try - { - skipReason = EvaluateSkipConditions(testMethod, conditionArguments); - return true; - } - catch (ConditionalDiscovererException e) - { - errorTestCase = new ExecutionErrorTestCase( - diagnosticMessageSink, - discoveryOptions.MethodDisplayOrDefault(), - discoveryOptions.MethodDisplayOptionsOrDefault(), - testMethod, - e.Message); - return false; - } - } - - internal static string GetFailedLookupString(string name, Type type) - { - return - $"An appropriate member '{name}' could not be found. " + - $"The conditional method needs to be a static method or property on the type {type} or any ancestor, " + - "of any visibility, accepting zero arguments, and having a return type of Boolean."; - } - - internal static MethodInfo LookupConditionalMethod(Type t, string name) - { - if (t == null || name == null) - return null; - - TypeInfo ti = t.GetTypeInfo(); - - MethodInfo mi = ti.GetDeclaredMethod(name); - if (mi != null && mi.IsStatic && mi.GetParameters().Length == 0 && mi.ReturnType == typeof(bool)) - return mi; - - PropertyInfo pi = ti.GetDeclaredProperty(name); - if (pi != null && pi.PropertyType == typeof(bool) && pi.GetMethod != null && pi.GetMethod.IsStatic && pi.GetMethod.GetParameters().Length == 0) - return pi.GetMethod; - - return LookupConditionalMethod(ti.BaseType, name); - } - - internal static bool CheckInputToSkipExecution(object[] conditionArguments, ref Type calleeType, ref string[] conditionMemberNames, ITestMethod testMethod = null) - { - // A null or empty list of conditionArguments is treated as "no conditions". - // and the test cases will be executed. - // Example: [ConditionalClass()] - if (conditionArguments == null || conditionArguments.Length == 0) - return true; - - calleeType = conditionArguments[0] as Type; - if (calleeType != null) - { - if (conditionArguments.Length < 2) - { - // [ConditionalFact(typeof(x))] no provided methods. - return true; - } - - // [ConditionalFact(typeof(x), "MethodName")] - conditionMemberNames = conditionArguments[1] as string[]; - } - else - { - // For [ConditionalClass], unable to get the Type info. All test cases will be executed. - if (testMethod == null) - return true; - - // [ConditionalFact("MethodName")] - conditionMemberNames = conditionArguments[0] as string[]; - } - - // [ConditionalFact((string[]) null)] - if (conditionMemberNames == null || conditionMemberNames.Count() == 0) - return true; - - return false; - } - } -} diff --git a/src/Microsoft.Data.SqlClient/tests/tools/Microsoft.DotNet.XUnitExtensions/Discoverers/ConditionalTheoryDiscoverer.cs b/src/Microsoft.Data.SqlClient/tests/tools/Microsoft.DotNet.XUnitExtensions/Discoverers/ConditionalTheoryDiscoverer.cs deleted file mode 100644 index 4bafc37a56..0000000000 --- a/src/Microsoft.Data.SqlClient/tests/tools/Microsoft.DotNet.XUnitExtensions/Discoverers/ConditionalTheoryDiscoverer.cs +++ /dev/null @@ -1,59 +0,0 @@ -// 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.Collections.Generic; -using System.Linq; -using Xunit.Abstractions; -using Xunit.Sdk; - -namespace Microsoft.DotNet.XUnitExtensions -{ - public class ConditionalTheoryDiscoverer : TheoryDiscoverer - { - private readonly Dictionary _conditionCache; - - public ConditionalTheoryDiscoverer(IMessageSink diagnosticMessageSink) : base(diagnosticMessageSink) - { - _conditionCache = new Dictionary(); - } - - protected override IEnumerable CreateTestCasesForTheory(ITestFrameworkDiscoveryOptions discoveryOptions, ITestMethod testMethod, IAttributeInfo theoryAttribute) - { - if (ConditionalTestDiscoverer.TryEvaluateSkipConditions(discoveryOptions, DiagnosticMessageSink, testMethod, theoryAttribute.GetConstructorArguments().ToArray(), out string skipReason, out ExecutionErrorTestCase errorTestCase)) - { - return skipReason != null - ? new[] { new SkippedTestCase(skipReason, DiagnosticMessageSink, discoveryOptions.MethodDisplayOrDefault(), discoveryOptions.MethodDisplayOptionsOrDefault(), testMethod) } - : new IXunitTestCase[] { new SkippedTheoryTestCase(DiagnosticMessageSink, discoveryOptions.MethodDisplayOrDefault(), discoveryOptions.MethodDisplayOptionsOrDefault(), testMethod) }; // Theory skippable at runtime. - } - - return new IXunitTestCase[] { errorTestCase }; - } - - protected override IEnumerable CreateTestCasesForDataRow(ITestFrameworkDiscoveryOptions discoveryOptions, ITestMethod testMethod, IAttributeInfo theoryAttribute, object[] dataRow) - { - IMethodInfo methodInfo = testMethod.Method; - List skippedTestCase = new List(); - - if (!_conditionCache.TryGetValue(methodInfo, out string skipReason)) - { - if (!ConditionalTestDiscoverer.TryEvaluateSkipConditions(discoveryOptions, DiagnosticMessageSink, testMethod, theoryAttribute.GetConstructorArguments().ToArray(), out skipReason, out ExecutionErrorTestCase errorTestCase)) - { - return new IXunitTestCase[] { errorTestCase }; - } - - _conditionCache.Add(methodInfo, skipReason); - - if (skipReason != null) - { - // If this is the first time we evalute the condition we return a SkippedTestCase to avoid printing a skip for every inline-data. - skippedTestCase.Add(new SkippedTestCase(skipReason, DiagnosticMessageSink, discoveryOptions.MethodDisplayOrDefault(), discoveryOptions.MethodDisplayOptionsOrDefault(), testMethod)); - } - } - - return skipReason != null ? - (IEnumerable)skippedTestCase - : new[] { new SkippedFactTestCase(DiagnosticMessageSink, discoveryOptions.MethodDisplayOrDefault(), discoveryOptions.MethodDisplayOptionsOrDefault(), testMethod, dataRow) }; // Test case skippable at runtime. - } - } -} diff --git a/src/Microsoft.Data.SqlClient/tests/tools/Microsoft.DotNet.XUnitExtensions/Discoverers/OuterLoopTestsDiscoverer.cs b/src/Microsoft.Data.SqlClient/tests/tools/Microsoft.DotNet.XUnitExtensions/Discoverers/OuterLoopTestsDiscoverer.cs deleted file mode 100644 index df6e168fd5..0000000000 --- a/src/Microsoft.Data.SqlClient/tests/tools/Microsoft.DotNet.XUnitExtensions/Discoverers/OuterLoopTestsDiscoverer.cs +++ /dev/null @@ -1,27 +0,0 @@ -// 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.Collections.Generic; -using Xunit.Abstractions; -using Xunit.Sdk; - -namespace Microsoft.DotNet.XUnitExtensions -{ - /// - /// This class discovers all of the tests and test classes that have - /// applied the OuterLoop attribute - /// - public class OuterLoopTestsDiscoverer : ITraitDiscoverer - { - /// - /// Gets the trait values from the Category attribute. - /// - /// The trait attribute containing the trait values. - /// The trait values. - public IEnumerable> GetTraits(IAttributeInfo traitAttribute) - { - yield return new KeyValuePair(XunitConstants.Category, XunitConstants.OuterLoop); - } - } -} diff --git a/src/Microsoft.Data.SqlClient/tests/tools/Microsoft.DotNet.XUnitExtensions/Discoverers/PlatformSpecificDiscoverer.cs b/src/Microsoft.Data.SqlClient/tests/tools/Microsoft.DotNet.XUnitExtensions/Discoverers/PlatformSpecificDiscoverer.cs deleted file mode 100644 index 1e7b5fe210..0000000000 --- a/src/Microsoft.Data.SqlClient/tests/tools/Microsoft.DotNet.XUnitExtensions/Discoverers/PlatformSpecificDiscoverer.cs +++ /dev/null @@ -1,39 +0,0 @@ -// 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.Collections.Generic; -using System.Linq; -using Xunit; -using Xunit.Abstractions; -using Xunit.Sdk; - -namespace Microsoft.DotNet.XUnitExtensions -{ - /// - /// This class discovers all of the tests and test classes that have - /// applied the PlatformSpecific attribute - /// - public class PlatformSpecificDiscoverer : ITraitDiscoverer - { - /// - /// Gets the trait values from the Category attribute. - /// - /// The trait attribute containing the trait values. - /// The trait values. - public IEnumerable> GetTraits(IAttributeInfo traitAttribute) - { - TestPlatforms platforms = (TestPlatforms)traitAttribute.GetConstructorArguments().First(); - if (!platforms.HasFlag(TestPlatforms.Windows)) - yield return new KeyValuePair(XunitConstants.Category, XunitConstants.NonWindowsTest); - if (!platforms.HasFlag(TestPlatforms.Linux)) - yield return new KeyValuePair(XunitConstants.Category, XunitConstants.NonLinuxTest); - if (!platforms.HasFlag(TestPlatforms.OSX)) - yield return new KeyValuePair(XunitConstants.Category, XunitConstants.NonOSXTest); - if (!platforms.HasFlag(TestPlatforms.FreeBSD)) - yield return new KeyValuePair(XunitConstants.Category, XunitConstants.NonFreeBSDTest); - if (!platforms.HasFlag(TestPlatforms.NetBSD)) - yield return new KeyValuePair(XunitConstants.Category, XunitConstants.NonNetBSDTest); - } - } -} diff --git a/src/Microsoft.Data.SqlClient/tests/tools/Microsoft.DotNet.XUnitExtensions/Discoverers/SkipOnCoreClrDiscoverer.cs b/src/Microsoft.Data.SqlClient/tests/tools/Microsoft.DotNet.XUnitExtensions/Discoverers/SkipOnCoreClrDiscoverer.cs deleted file mode 100644 index d3bc7529bb..0000000000 --- a/src/Microsoft.Data.SqlClient/tests/tools/Microsoft.DotNet.XUnitExtensions/Discoverers/SkipOnCoreClrDiscoverer.cs +++ /dev/null @@ -1,103 +0,0 @@ -// 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.Collections.Generic; -using System.Linq; -using System.Reflection; -using Xunit; -using Xunit.Abstractions; -using Xunit.Sdk; - -namespace Microsoft.DotNet.XUnitExtensions -{ - public class SkipOnCoreClrDiscoverer : ITraitDiscoverer - { - public IEnumerable> GetTraits(IAttributeInfo traitAttribute) - { - if (!SkipOnMonoDiscoverer.IsMonoRuntime) - { - TestPlatforms testPlatforms = TestPlatforms.Any; - RuntimeStressTestModes stressMode = RuntimeStressTestModes.Any; - foreach (object arg in traitAttribute.GetConstructorArguments().Skip(1)) // We skip the first one as it is the reason - { - if (arg is TestPlatforms tp) - { - testPlatforms = tp; - } - else if (arg is RuntimeStressTestModes rstm) - { - stressMode = rstm; - } - } - - if (DiscovererHelpers.TestPlatformApplies(testPlatforms) && StressModeApplies(stressMode)) - { - if (IsCheckedRuntime() || (IsRuntimeStressTesting && !stressMode.HasFlag(RuntimeStressTestModes.CheckedRuntime))) - { - return new[] { new KeyValuePair(XunitConstants.Category, XunitConstants.Failing) }; - } - } - } - - return Array.Empty>(); - } - - // Order here matters as some env variables may appear in multiple modes - private static bool StressModeApplies(RuntimeStressTestModes stressMode) => - stressMode == RuntimeStressTestModes.Any || - (stressMode.HasFlag(RuntimeStressTestModes.GCStress3) && IsGCStress3) || - (stressMode.HasFlag(RuntimeStressTestModes.GCStressC) && IsGCStressC) || - (stressMode.HasFlag(RuntimeStressTestModes.ZapDisable) && IsZapDisable) || - (stressMode.HasFlag(RuntimeStressTestModes.TailcallStress) && IsTailCallStress) || - (stressMode.HasFlag(RuntimeStressTestModes.JitStressRegs) && IsJitStressRegs) || - (stressMode.HasFlag(RuntimeStressTestModes.JitStress) && IsJitStress) || - (stressMode.HasFlag(RuntimeStressTestModes.JitMinOpts) && IsJitMinOpts) || - stressMode == RuntimeStressTestModes.CheckedRuntime; // if checked runtime is the only flag, all stress modes apply. - - // Order here matters as some env variables may appear in multiple modes - private static bool IsRuntimeStressTesting => - IsGCStress3 || - IsGCStressC || - IsZapDisable || - IsTailCallStress || - IsJitStressRegs || - IsJitStress || - IsJitMinOpts; - - private static string GetEnvironmentVariableValue(string name) => Environment.GetEnvironmentVariable(name) ?? "0"; - - private static bool IsJitStress => !string.Equals(GetEnvironmentVariableValue("COMPlus_JitStress"), "0", StringComparison.InvariantCulture); - - private static bool IsJitStressRegs => !string.Equals(GetEnvironmentVariableValue("COMPlus_JitStressRegs"), "0", StringComparison.InvariantCulture); - - private static bool IsJitMinOpts => string.Equals(GetEnvironmentVariableValue("COMPlus_JITMinOpts"), "1", StringComparison.InvariantCulture); - - private static bool IsTailCallStress => string.Equals(GetEnvironmentVariableValue("COMPlus_TailcallStress"), "1", StringComparison.InvariantCulture); - - private static bool IsZapDisable => string.Equals(GetEnvironmentVariableValue("COMPlus_ZapDisable"), "1", StringComparison.InvariantCulture); - - private static bool IsGCStress3 => CompareGCStressModeAsLower(GetEnvironmentVariableValue("COMPlus_GCStress"), "0x3", "3"); - - private static bool IsGCStressC => CompareGCStressModeAsLower(GetEnvironmentVariableValue("COMPlus_GCStress"), "0xC", "C"); - - private static bool IsCheckedRuntime() - { - Assembly assembly = typeof(string).Assembly; - AssemblyConfigurationAttribute assemblyConfigurationAttribute = assembly.GetCustomAttribute(); - - return assemblyConfigurationAttribute != null && - string.Equals(assemblyConfigurationAttribute.Configuration, "Checked", StringComparison.InvariantCulture); - } - - private static bool CompareGCStressModeAsLower(string value, string first, string second) - { - value = value.ToLowerInvariant(); - return string.Equals(value, first.ToLowerInvariant(), StringComparison.InvariantCulture) || - string.Equals(value, second.ToLowerInvariant(), StringComparison.InvariantCulture) || - string.Equals(value, "0xf", StringComparison.InvariantCulture) || - string.Equals(value, "f", StringComparison.InvariantCulture); - } - } -} diff --git a/src/Microsoft.Data.SqlClient/tests/tools/Microsoft.DotNet.XUnitExtensions/Discoverers/SkipOnMonoDiscoverer.cs b/src/Microsoft.Data.SqlClient/tests/tools/Microsoft.DotNet.XUnitExtensions/Discoverers/SkipOnMonoDiscoverer.cs deleted file mode 100644 index 45e99abce5..0000000000 --- a/src/Microsoft.Data.SqlClient/tests/tools/Microsoft.DotNet.XUnitExtensions/Discoverers/SkipOnMonoDiscoverer.cs +++ /dev/null @@ -1,39 +0,0 @@ -// 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.Collections.Generic; -using System.Linq; -using Xunit; -using Xunit.Abstractions; -using Xunit.Sdk; - -namespace Microsoft.DotNet.XUnitExtensions -{ - public class SkipOnMonoDiscoverer : ITraitDiscoverer - { - public IEnumerable> GetTraits(IAttributeInfo traitAttribute) - { - if (IsMonoRuntime) - { - TestPlatforms testPlatforms = TestPlatforms.Any; - - // Last argument is either the TestPlatform or the test platform to skip the test on. - if (traitAttribute.GetConstructorArguments().LastOrDefault() is TestPlatforms tp) - { - testPlatforms = tp; - } - - if (DiscovererHelpers.TestPlatformApplies(testPlatforms)) - { - return new[] { new KeyValuePair(XunitConstants.Category, XunitConstants.Failing) }; - } - } - - return Array.Empty>(); - } - - public static bool IsMonoRuntime => Type.GetType("Mono.RuntimeStructs") != null; - } -} diff --git a/src/Microsoft.Data.SqlClient/tests/tools/Microsoft.DotNet.XUnitExtensions/Discoverers/SkipOnTargetFrameworkDiscoverer.cs b/src/Microsoft.Data.SqlClient/tests/tools/Microsoft.DotNet.XUnitExtensions/Discoverers/SkipOnTargetFrameworkDiscoverer.cs deleted file mode 100644 index 7e031f2650..0000000000 --- a/src/Microsoft.Data.SqlClient/tests/tools/Microsoft.DotNet.XUnitExtensions/Discoverers/SkipOnTargetFrameworkDiscoverer.cs +++ /dev/null @@ -1,37 +0,0 @@ -// 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.Collections.Generic; -using System.Linq; -using Xunit; -using Xunit.Abstractions; -using Xunit.Sdk; - -namespace Microsoft.DotNet.XUnitExtensions -{ - /// - /// This class discovers all of the tests and test classes that have - /// applied the TestOnTargetFrameworkDiscoverer attribute - /// - public class SkipOnTargetFrameworkDiscoverer : ITraitDiscoverer - { - /// - /// Gets the trait values from the Category attribute. - /// - /// The trait attribute containing the trait values. - /// The trait values. - public IEnumerable> GetTraits(IAttributeInfo traitAttribute) - { - TargetFrameworkMonikers frameworks = (TargetFrameworkMonikers)traitAttribute.GetConstructorArguments().First(); - if (frameworks.HasFlag(TargetFrameworkMonikers.Netcoreapp)) - yield return new KeyValuePair(XunitConstants.Category, XunitConstants.NonNetcoreappTest); - if (frameworks.HasFlag(TargetFrameworkMonikers.NetFramework)) - yield return new KeyValuePair(XunitConstants.Category, XunitConstants.NonNetfxTest); - if (frameworks.HasFlag(TargetFrameworkMonikers.Uap)) - yield return new KeyValuePair(XunitConstants.Category, XunitConstants.NonUapTest); - if (frameworks.HasFlag(TargetFrameworkMonikers.Mono)) - yield return new KeyValuePair(XunitConstants.Category, XunitConstants.NonMonoTest); - } - } -} diff --git a/src/Microsoft.Data.SqlClient/tests/tools/Microsoft.DotNet.XUnitExtensions/Discoverers/TestCategoryDiscoverer.cs b/src/Microsoft.Data.SqlClient/tests/tools/Microsoft.DotNet.XUnitExtensions/Discoverers/TestCategoryDiscoverer.cs deleted file mode 100644 index 4f30e9c42d..0000000000 --- a/src/Microsoft.Data.SqlClient/tests/tools/Microsoft.DotNet.XUnitExtensions/Discoverers/TestCategoryDiscoverer.cs +++ /dev/null @@ -1,31 +0,0 @@ -// 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.Collections.Generic; -using System.Linq; -using Xunit.Abstractions; -using Xunit.Sdk; - -/// -/// This is a replacement for the MSTest [TestCategoryAttribute] on xunit -/// xunit does not have the concept of Category for tests and instead, the have [TraitAttribute(string key, string value)] -/// If we replace the MSTest [TestCategoryAttribute] for the [TestCategory("BVT")], we will surely fall at some time in cases -/// where people will typo on the "Category" key part of the Trait. -/// On order to achieve the same behaviour as on MSTest, a custom [TestCategory] was created -/// to mimic the MSTest one and avoid replace it on every existent test. -/// The tests can be filtered by xunit runners by usage of "-trait" on the command line with the expression like -/// -trait "Category=BVT" for example that will only run the tests with [TestCategory("BVT")] on it. -/// - -namespace Microsoft.DotNet.XUnitExtensions -{ - public class TestCategoryDiscoverer : ITraitDiscoverer - { - public IEnumerable> GetTraits(IAttributeInfo traitAttribute) - { - var ctorArgs = traitAttribute.GetConstructorArguments().ToList(); - yield return new KeyValuePair("Category", ctorArgs[0].ToString()); - } - } -} diff --git a/src/Microsoft.Data.SqlClient/tests/tools/Microsoft.DotNet.XUnitExtensions/Extensions/PlatformDetection.cs b/src/Microsoft.Data.SqlClient/tests/tools/Microsoft.DotNet.XUnitExtensions/Extensions/PlatformDetection.cs deleted file mode 100644 index 24b9e24b4f..0000000000 --- a/src/Microsoft.Data.SqlClient/tests/tools/Microsoft.DotNet.XUnitExtensions/Extensions/PlatformDetection.cs +++ /dev/null @@ -1,16 +0,0 @@ -// 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.Runtime.InteropServices; - -namespace System -{ - public static partial class PlatformDetection - { - public static bool IsArmProcess => RuntimeInformation.ProcessArchitecture == Architecture.Arm; - public static bool IsNotArmProcess => !IsArmProcess; - public static bool IsX86Process => RuntimeInformation.ProcessArchitecture == Architecture.X86; - public static bool IsNotX86Process => !IsX86Process; - } -} diff --git a/src/Microsoft.Data.SqlClient/tests/tools/Microsoft.DotNet.XUnitExtensions/Extensions/TheoryExtensions.cs b/src/Microsoft.Data.SqlClient/tests/tools/Microsoft.DotNet.XUnitExtensions/Extensions/TheoryExtensions.cs deleted file mode 100644 index 110af4dedb..0000000000 --- a/src/Microsoft.Data.SqlClient/tests/tools/Microsoft.DotNet.XUnitExtensions/Extensions/TheoryExtensions.cs +++ /dev/null @@ -1,38 +0,0 @@ -// 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.Collections; -using System.Collections.Generic; -using System.Linq; -using Xunit; - -namespace Microsoft.DotNet.XUnitExtensions -{ - public static class TheoryExtensions - { - /// - /// Converts an IEnumerable into an Xunit theory compatible enumerable. - /// - public static TheoryData ToTheoryData(this IEnumerable data) - { - // Returning TheoryData rather than IEnumerable directly should - // encourage discover and usage of TheoryData classes for more - // complicated theories. Slightly easier to type as well. - return new TheoryDataAdapter(data.Select(d => new object[] { d })); - } - - private class TheoryDataAdapter : TheoryData, IEnumerable - { - private IEnumerable _data; - - public TheoryDataAdapter(IEnumerable data) - { - _data = data; - } - - public new IEnumerator GetEnumerator() => _data.GetEnumerator(); - IEnumerator IEnumerable.GetEnumerator() => GetEnumerator(); - } - } -} diff --git a/src/Microsoft.Data.SqlClient/tests/tools/Microsoft.DotNet.XUnitExtensions/Microsoft.DotNet.XUnitExtensions.csproj b/src/Microsoft.Data.SqlClient/tests/tools/Microsoft.DotNet.XUnitExtensions/Microsoft.DotNet.XUnitExtensions.csproj deleted file mode 100644 index a61443eafe..0000000000 --- a/src/Microsoft.Data.SqlClient/tests/tools/Microsoft.DotNet.XUnitExtensions/Microsoft.DotNet.XUnitExtensions.csproj +++ /dev/null @@ -1,56 +0,0 @@ - - - Microsoft.DotNet.XUnitExtensions - netcoreapp - netfx - false - $(ObjFolder)$(Configuration).$(Platform)\$(AssemblyName) - $(BinFolder)$(Configuration).$(Platform)\$(AssemblyName) - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/Microsoft.Data.SqlClient/tests/tools/Microsoft.DotNet.XUnitExtensions/RuntimeStressTestModes.cs b/src/Microsoft.Data.SqlClient/tests/tools/Microsoft.DotNet.XUnitExtensions/RuntimeStressTestModes.cs deleted file mode 100644 index 356c7a2910..0000000000 --- a/src/Microsoft.Data.SqlClient/tests/tools/Microsoft.DotNet.XUnitExtensions/RuntimeStressTestModes.cs +++ /dev/null @@ -1,39 +0,0 @@ -// 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; - -namespace Xunit -{ - [Flags] - public enum RuntimeStressTestModes - { - // Disable on any stress test mode or on checked runtime. - // Can't be ~0 as that would include CheckedRuntime flag, which would break the case - // where you want to disable in all (including release stress test). - Any = 0, - - // JitStress, JitStressRegs, JitMinOpts and TailcallStress enable - // various modes in the JIT that cause us to exercise more code paths, - // and generate different kinds of code - JitStress = 1, // COMPlus_JitStress is set. - JitStressRegs = 1 << 1, // COMPlus_JitStressRegs is set. - JitMinOpts = 1 << 2, // COMPlus_JITMinOpts is set. - TailcallStress = 1 << 3, // COMPlus_TailcallStress is set. - - // ZapDisable says to not use NGEN or ReadyToRun images. - // This means we JIT everything. - ZapDisable = 1 << 4, // COMPlus_ZapDisable is set. - - // GCStress3 forces a GC at various locations, typically transitions - // to/from the VM from managed code. - GCStress3 = 1 << 5, // COMPlus_GCStress includes mode 0x3. - - // GCStressC forces a GC at every JIT-generated code instruction, - // including in NGEN/ReadyToRun code. - GCStressC = 1 << 6, // COMPlus_GCStress includes mode 0xC. - CheckedRuntime = 1 << 7, // Disable only when running on checked runtime. - AnyGCStress = GCStress3 | GCStressC // Disable when any GCStress is exercised. - } -} diff --git a/src/Microsoft.Data.SqlClient/tests/tools/Microsoft.DotNet.XUnitExtensions/SkippedFactTestCase.cs b/src/Microsoft.Data.SqlClient/tests/tools/Microsoft.DotNet.XUnitExtensions/SkippedFactTestCase.cs deleted file mode 100644 index 9c05dd4915..0000000000 --- a/src/Microsoft.Data.SqlClient/tests/tools/Microsoft.DotNet.XUnitExtensions/SkippedFactTestCase.cs +++ /dev/null @@ -1,39 +0,0 @@ -// 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.Threading; -using System.Threading.Tasks; -using Xunit.Abstractions; -using Xunit.Sdk; - -namespace Microsoft.DotNet.XUnitExtensions -{ - /// Wraps RunAsync for ConditionalFact. - public class SkippedFactTestCase : XunitTestCase - { - [Obsolete("Called by the de-serializer; should only be called by deriving classes for de-serialization purposes", error: true)] - public SkippedFactTestCase() { } - - public SkippedFactTestCase(IMessageSink diagnosticMessageSink, TestMethodDisplay defaultMethodDisplay, TestMethodDisplayOptions defaultMethodDisplayOptions, ITestMethod testMethod, object[] testMethodArguments = null) - : base(diagnosticMessageSink, defaultMethodDisplay, defaultMethodDisplayOptions, testMethod, testMethodArguments) { } - - public override async Task RunAsync(IMessageSink diagnosticMessageSink, - IMessageBus messageBus, - object[] constructorArguments, - ExceptionAggregator aggregator, - CancellationTokenSource cancellationTokenSource) - { - SkippedTestMessageBus skipMessageBus = new SkippedTestMessageBus(messageBus); - var result = await base.RunAsync(diagnosticMessageSink, skipMessageBus, constructorArguments, aggregator, cancellationTokenSource); - if (skipMessageBus.SkippedTestCount > 0) - { - result.Failed -= skipMessageBus.SkippedTestCount; - result.Skipped += skipMessageBus.SkippedTestCount; - } - - return result; - } - } -} diff --git a/src/Microsoft.Data.SqlClient/tests/tools/Microsoft.DotNet.XUnitExtensions/SkippedTestCase.cs b/src/Microsoft.Data.SqlClient/tests/tools/Microsoft.DotNet.XUnitExtensions/SkippedTestCase.cs deleted file mode 100644 index 5f1a9079dc..0000000000 --- a/src/Microsoft.Data.SqlClient/tests/tools/Microsoft.DotNet.XUnitExtensions/SkippedTestCase.cs +++ /dev/null @@ -1,48 +0,0 @@ -// 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 Xunit.Abstractions; -using Xunit.Sdk; - -namespace Microsoft.DotNet.XUnitExtensions -{ - /// Wraps another test case that should be skipped. - internal sealed class SkippedTestCase : XunitTestCase - { - private string _skipReason; - - [Obsolete("Called by the de-serializer; should only be called by deriving classes for de-serialization purposes")] - public SkippedTestCase() : base() - { - } - - public SkippedTestCase( - string skipReason, - IMessageSink diagnosticMessageSink, - TestMethodDisplay defaultMethodDisplay, - TestMethodDisplayOptions defaultMethodDisplayOptions, - ITestMethod testMethod, - object[] testMethodArguments = null) - : base(diagnosticMessageSink, defaultMethodDisplay, defaultMethodDisplayOptions, testMethod, testMethodArguments) - { - _skipReason = skipReason; - } - - protected override string GetSkipReason(IAttributeInfo factAttribute) - => _skipReason ?? base.GetSkipReason(factAttribute); - - public override void Deserialize(IXunitSerializationInfo data) - { - base.Deserialize(data); - _skipReason = data.GetValue(nameof(_skipReason)); - } - - public override void Serialize(IXunitSerializationInfo data) - { - base.Serialize(data); - data.AddValue(nameof(_skipReason), _skipReason); - } - } -} diff --git a/src/Microsoft.Data.SqlClient/tests/tools/Microsoft.DotNet.XUnitExtensions/SkippedTestMessageBus.cs b/src/Microsoft.Data.SqlClient/tests/tools/Microsoft.DotNet.XUnitExtensions/SkippedTestMessageBus.cs deleted file mode 100644 index 12f8e28e74..0000000000 --- a/src/Microsoft.Data.SqlClient/tests/tools/Microsoft.DotNet.XUnitExtensions/SkippedTestMessageBus.cs +++ /dev/null @@ -1,50 +0,0 @@ -// 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.Linq; -using Xunit.Abstractions; -using Xunit.Sdk; - -namespace Microsoft.DotNet.XUnitExtensions -{ - public class SkipTestException : Exception - { - public SkipTestException(string reason) - : base(reason) { } - } - - /// Implements message bus to communicate tests skipped via SkipTestException. - public class SkippedTestMessageBus : IMessageBus - { - readonly IMessageBus innerBus; - - public SkippedTestMessageBus(IMessageBus innerBus) - { - this.innerBus = innerBus; - } - - public int SkippedTestCount { get; private set; } - - public void Dispose() { } - - public bool QueueMessage(IMessageSinkMessage message) - { - var testFailed = message as ITestFailed; - - if (testFailed != null) - { - var exceptionType = testFailed.ExceptionTypes.FirstOrDefault(); - if (exceptionType == typeof(SkipTestException).FullName) - { - SkippedTestCount++; - return innerBus.QueueMessage(new TestSkipped(testFailed.Test, testFailed.Messages.FirstOrDefault())); - } - } - - // Nothing we care about, send it on its way - return innerBus.QueueMessage(message); - } - } -} diff --git a/src/Microsoft.Data.SqlClient/tests/tools/Microsoft.DotNet.XUnitExtensions/SkippedTheoryTestCase.cs b/src/Microsoft.Data.SqlClient/tests/tools/Microsoft.DotNet.XUnitExtensions/SkippedTheoryTestCase.cs deleted file mode 100644 index abcf828bd1..0000000000 --- a/src/Microsoft.Data.SqlClient/tests/tools/Microsoft.DotNet.XUnitExtensions/SkippedTheoryTestCase.cs +++ /dev/null @@ -1,39 +0,0 @@ -// 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.Threading; -using System.Threading.Tasks; -using Xunit.Abstractions; -using Xunit.Sdk; - -namespace Microsoft.DotNet.XUnitExtensions -{ - /// Wraps RunAsync for ConditionalTheory. - public class SkippedTheoryTestCase : XunitTheoryTestCase - { - [Obsolete("Called by the de-serializer; should only be called by deriving classes for de-serialization purposes", error: true)] - public SkippedTheoryTestCase() { } - - public SkippedTheoryTestCase(IMessageSink diagnosticMessageSink, TestMethodDisplay defaultMethodDisplay, TestMethodDisplayOptions defaultMethodDisplayOptions, ITestMethod testMethod) - : base(diagnosticMessageSink, defaultMethodDisplay, defaultMethodDisplayOptions, testMethod) { } - - public override async Task RunAsync(IMessageSink diagnosticMessageSink, - IMessageBus messageBus, - object[] constructorArguments, - ExceptionAggregator aggregator, - CancellationTokenSource cancellationTokenSource) - { - SkippedTestMessageBus skipMessageBus = new SkippedTestMessageBus(messageBus); - var result = await base.RunAsync(diagnosticMessageSink, skipMessageBus, constructorArguments, aggregator, cancellationTokenSource); - if (skipMessageBus.SkippedTestCount > 0) - { - result.Failed -= skipMessageBus.SkippedTestCount; - result.Skipped += skipMessageBus.SkippedTestCount; - } - - return result; - } - } -} diff --git a/src/Microsoft.Data.SqlClient/tests/tools/Microsoft.DotNet.XUnitExtensions/TargetFrameworkMonikers.cs b/src/Microsoft.Data.SqlClient/tests/tools/Microsoft.DotNet.XUnitExtensions/TargetFrameworkMonikers.cs deleted file mode 100644 index 182768f741..0000000000 --- a/src/Microsoft.Data.SqlClient/tests/tools/Microsoft.DotNet.XUnitExtensions/TargetFrameworkMonikers.cs +++ /dev/null @@ -1,17 +0,0 @@ -// 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; - -namespace Xunit -{ - [Flags] - public enum TargetFrameworkMonikers - { - Netcoreapp = 0x1, - NetFramework = 0x2, - Uap = 0x4, - Mono = 0x8 - } -} diff --git a/src/Microsoft.Data.SqlClient/tests/tools/Microsoft.DotNet.XUnitExtensions/TestPlatforms.cs b/src/Microsoft.Data.SqlClient/tests/tools/Microsoft.DotNet.XUnitExtensions/TestPlatforms.cs deleted file mode 100644 index fe905803be..0000000000 --- a/src/Microsoft.Data.SqlClient/tests/tools/Microsoft.DotNet.XUnitExtensions/TestPlatforms.cs +++ /dev/null @@ -1,20 +0,0 @@ -// 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; - -namespace Xunit -{ - [Flags] - public enum TestPlatforms - { - Windows = 1, - Linux = 2, - OSX = 4, - FreeBSD = 8, - NetBSD = 16, - AnyUnix = FreeBSD | Linux | NetBSD | OSX, - Any = ~0 - } -} diff --git a/src/Microsoft.Data.SqlClient/tests/tools/Microsoft.DotNet.XUnitExtensions/XunitConstants.cs b/src/Microsoft.Data.SqlClient/tests/tools/Microsoft.DotNet.XUnitExtensions/XunitConstants.cs deleted file mode 100644 index 870342bd15..0000000000 --- a/src/Microsoft.Data.SqlClient/tests/tools/Microsoft.DotNet.XUnitExtensions/XunitConstants.cs +++ /dev/null @@ -1,28 +0,0 @@ -// 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. - -namespace Microsoft.DotNet.XUnitExtensions -{ - public struct XunitConstants - { - internal const string NonFreeBSDTest = "nonfreebsdtests"; - internal const string NonLinuxTest = "nonlinuxtests"; - internal const string NonNetBSDTest = "nonnetbsdtests"; - internal const string NonOSXTest = "nonosxtests"; - internal const string NonWindowsTest = "nonwindowstests"; - - internal static string NonNetcoreappTest = "nonnetcoreapptests"; - internal static string NonNetfxTest = "nonnetfxtests"; - internal static string NonUapTest = "nonuaptests"; - internal static string NonMonoTest = "nonmonotests"; - - internal const string Failing = "failing"; - internal const string ActiveIssue = "activeissue"; - internal const string OuterLoop = "outerloop"; - - public const string Category = "category"; - public const string IgnoreForCI = "ignoreforci"; - public const string RequiresElevation = "requireselevation"; - } -} diff --git a/tools/props/Versions.props b/tools/props/Versions.props index f57611a6b6..4c9ce65e19 100644 --- a/tools/props/Versions.props +++ b/tools/props/Versions.props @@ -51,7 +51,7 @@ 4.3.0 - 6.0.1 + 7.0.2 @@ -61,15 +61,16 @@ + 9.0.0-beta.23506.2 3.1.6 5.2.9 - 17.4.1 + 17.7.2 13.0.1 4.3.0 6.0.1 6.24.0 - 2.4.2 - 2.4.5 + 2.5.1 + 1.0.3 7.0.0-beta.22316.1 2.0.8 170.8.0 @@ -77,7 +78,7 @@ 160.1000.6 0.13.2 6.0.0 - 6.0.0 + 7.0.1 $(NugetPackageVersion)