From b3d37b9311b62fe9dcdd949767bd2ec9c2dac209 Mon Sep 17 00:00:00 2001 From: "Saurabh Singh (SQL)" Date: Mon, 20 May 2019 15:23:38 -0700 Subject: [PATCH 01/13] adding debug logs for OleDb failures --- .../tests/OleDbCommandBuilderTests.cs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/System.Data.OleDb/tests/OleDbCommandBuilderTests.cs b/src/System.Data.OleDb/tests/OleDbCommandBuilderTests.cs index 9759e41a9452..02417dfbc7fd 100644 --- a/src/System.Data.OleDb/tests/OleDbCommandBuilderTests.cs +++ b/src/System.Data.OleDb/tests/OleDbCommandBuilderTests.cs @@ -4,6 +4,7 @@ using System.IO; using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; using Xunit; namespace System.Data.OleDb.Tests @@ -154,7 +155,18 @@ private void RunTest(Action testAction, [CallerMemberName] Firstname NVARCHAR(5), Lastname NVARCHAR(40), Nickname NVARCHAR(30))"; + try + { command.ExecuteNonQuery(); + } + catch (SEHException sehEx) + { + Console.WriteLine($"Code: {sehEx.ErrorCode}"); + Console.WriteLine($"Base Exception error code : {sehEx.GetBaseException().HResult}"); + Console.WriteLine($"Base Exception error code : {sehEx.GetBaseException().ToString()}"); + Console.WriteLine($"Base Inner Exception: {sehEx.InnerException}"); + throw; + } Assert.True(File.Exists(Path.Combine(TestDirectory, tableName))); command.CommandText = From 151adcea2e3b54811f972ea6ad3e3018317890ce Mon Sep 17 00:00:00 2001 From: "Saurabh Singh (SQL)" Date: Mon, 20 May 2019 15:26:21 -0700 Subject: [PATCH 02/13] Fix indentation --- src/System.Data.OleDb/tests/OleDbCommandBuilderTests.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/System.Data.OleDb/tests/OleDbCommandBuilderTests.cs b/src/System.Data.OleDb/tests/OleDbCommandBuilderTests.cs index 02417dfbc7fd..017e5dd0f9d5 100644 --- a/src/System.Data.OleDb/tests/OleDbCommandBuilderTests.cs +++ b/src/System.Data.OleDb/tests/OleDbCommandBuilderTests.cs @@ -157,7 +157,7 @@ Lastname NVARCHAR(40), Nickname NVARCHAR(30))"; try { - command.ExecuteNonQuery(); + command.ExecuteNonQuery(); } catch (SEHException sehEx) { From 4a92fec3153f179493e26ccdc4112e87c974bec8 Mon Sep 17 00:00:00 2001 From: "Saurabh Singh (SQL)" Date: Mon, 20 May 2019 15:28:06 -0700 Subject: [PATCH 03/13] add comments to why we are re throwing --- src/System.Data.OleDb/tests/OleDbCommandBuilderTests.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/System.Data.OleDb/tests/OleDbCommandBuilderTests.cs b/src/System.Data.OleDb/tests/OleDbCommandBuilderTests.cs index 017e5dd0f9d5..7e9b19ed6bd6 100644 --- a/src/System.Data.OleDb/tests/OleDbCommandBuilderTests.cs +++ b/src/System.Data.OleDb/tests/OleDbCommandBuilderTests.cs @@ -165,6 +165,8 @@ Lastname NVARCHAR(40), Console.WriteLine($"Base Exception error code : {sehEx.GetBaseException().HResult}"); Console.WriteLine($"Base Exception error code : {sehEx.GetBaseException().ToString()}"); Console.WriteLine($"Base Inner Exception: {sehEx.InnerException}"); + + // This exception is not expected. So rethrow to indicate test failure. throw; } Assert.True(File.Exists(Path.Combine(TestDirectory, tableName))); From 58a620b541fb059a4309a66cde4d180f371fab59 Mon Sep 17 00:00:00 2001 From: "Saurabh Singh (SQL)" Date: Mon, 20 May 2019 15:29:12 -0700 Subject: [PATCH 04/13] Improve error message --- src/System.Data.OleDb/tests/OleDbCommandBuilderTests.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/System.Data.OleDb/tests/OleDbCommandBuilderTests.cs b/src/System.Data.OleDb/tests/OleDbCommandBuilderTests.cs index 7e9b19ed6bd6..f009ecfc8481 100644 --- a/src/System.Data.OleDb/tests/OleDbCommandBuilderTests.cs +++ b/src/System.Data.OleDb/tests/OleDbCommandBuilderTests.cs @@ -163,7 +163,7 @@ Lastname NVARCHAR(40), { Console.WriteLine($"Code: {sehEx.ErrorCode}"); Console.WriteLine($"Base Exception error code : {sehEx.GetBaseException().HResult}"); - Console.WriteLine($"Base Exception error code : {sehEx.GetBaseException().ToString()}"); + Console.WriteLine($"Base Exception message : {sehEx.GetBaseException().ToString()}"); Console.WriteLine($"Base Inner Exception: {sehEx.InnerException}"); // This exception is not expected. So rethrow to indicate test failure. From 933bb1d58cfc9c8b1620dab20165630fc2c9024a Mon Sep 17 00:00:00 2001 From: "Saurabh Singh (SQL)" Date: Mon, 20 May 2019 15:30:05 -0700 Subject: [PATCH 05/13] Prevent NRE in case base exception is null --- src/System.Data.OleDb/tests/OleDbCommandBuilderTests.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/System.Data.OleDb/tests/OleDbCommandBuilderTests.cs b/src/System.Data.OleDb/tests/OleDbCommandBuilderTests.cs index f009ecfc8481..07851284fc3d 100644 --- a/src/System.Data.OleDb/tests/OleDbCommandBuilderTests.cs +++ b/src/System.Data.OleDb/tests/OleDbCommandBuilderTests.cs @@ -163,7 +163,7 @@ Lastname NVARCHAR(40), { Console.WriteLine($"Code: {sehEx.ErrorCode}"); Console.WriteLine($"Base Exception error code : {sehEx.GetBaseException().HResult}"); - Console.WriteLine($"Base Exception message : {sehEx.GetBaseException().ToString()}"); + Console.WriteLine($"Base Exception message : {sehEx.GetBaseException()?.ToString()}"); Console.WriteLine($"Base Inner Exception: {sehEx.InnerException}"); // This exception is not expected. So rethrow to indicate test failure. From 0484aad70fe2cb2b27cd042a8ba9998ae726b616 Mon Sep 17 00:00:00 2001 From: Maryam Ariyan Date: Tue, 21 May 2019 08:52:27 -0700 Subject: [PATCH 06/13] skip on x86 and when both drivers installed --- src/System.Data.OleDb/tests/Helpers.cs | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/src/System.Data.OleDb/tests/Helpers.cs b/src/System.Data.OleDb/tests/Helpers.cs index 087f92abf5c5..531281e9cf45 100644 --- a/src/System.Data.OleDb/tests/Helpers.cs +++ b/src/System.Data.OleDb/tests/Helpers.cs @@ -20,22 +20,26 @@ private class Nested public static readonly string ProviderName; public static Nested Instance => s_instance; private static readonly Nested s_instance = new Nested(); + private static readonly string s_expectedProviderName = @"Microsoft.ACE.OLEDB.12.0"; private Nested() { } static Nested() { + bool shouldSkip = false; // Get the sources rowset for the SQLOLEDB enumerator DataTable table = (new OleDbEnumerator()).GetElements(); DataColumn providersRegistered = table.Columns["SOURCES_NAME"]; List providerNames = new List(); foreach (DataRow row in table.Rows) { - providerNames.Add(row[providersRegistered]); + var curProvider = (string)row[providersRegistered]; + if (curProvider.Contains("JET")) + shouldSkip = true; // JET driver installed + providerNames.Add(curProvider); } - string providerName = PlatformDetection.Is32BitProcess ? - @"Microsoft.Jet.OLEDB.4.0" : - @"Microsoft.ACE.OLEDB.12.0"; - IsAvailable = false; // ActiveIssue #37823 // providerNames.Contains(providerName); - ProviderName = IsAvailable ? providerName : null; + // skip if x86 or if both drivers available + shouldSkip |= PlatformDetection.Is32BitProcess; + IsAvailable = !shouldSkip && providerNames.Contains(s_expectedProviderName); + ProviderName = IsAvailable ? s_expectedProviderName : null; } } } From 216985a0a1d82450f8318babf4149fcdf27b5ecb Mon Sep 17 00:00:00 2001 From: Maryam Ariyan Date: Mon, 3 Jun 2019 18:33:51 -0700 Subject: [PATCH 07/13] code cleanup --- src/System.Data.OleDb/tests/Helpers.cs | 8 ++++---- src/System.Data.OleDb/tests/OleDbCommandBuilderTests.cs | 8 ++++++-- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/src/System.Data.OleDb/tests/Helpers.cs b/src/System.Data.OleDb/tests/Helpers.cs index 531281e9cf45..2862aef062ae 100644 --- a/src/System.Data.OleDb/tests/Helpers.cs +++ b/src/System.Data.OleDb/tests/Helpers.cs @@ -24,7 +24,7 @@ private class Nested private Nested() { } static Nested() { - bool shouldSkip = false; + bool jetDriverInstalled = false; // Get the sources rowset for the SQLOLEDB enumerator DataTable table = (new OleDbEnumerator()).GetElements(); DataColumn providersRegistered = table.Columns["SOURCES_NAME"]; @@ -33,12 +33,12 @@ static Nested() { var curProvider = (string)row[providersRegistered]; if (curProvider.Contains("JET")) - shouldSkip = true; // JET driver installed + jetDriverInstalled = true; providerNames.Add(curProvider); } // skip if x86 or if both drivers available - shouldSkip |= PlatformDetection.Is32BitProcess; - IsAvailable = !shouldSkip && providerNames.Contains(s_expectedProviderName); + IsAvailable = !PlatformDetection.Is32BitProcess && + !(jetDriverInstalled && providerNames.Contains(s_expectedProviderName)); ProviderName = IsAvailable ? s_expectedProviderName : null; } } diff --git a/src/System.Data.OleDb/tests/OleDbCommandBuilderTests.cs b/src/System.Data.OleDb/tests/OleDbCommandBuilderTests.cs index 07851284fc3d..917bf487366e 100644 --- a/src/System.Data.OleDb/tests/OleDbCommandBuilderTests.cs +++ b/src/System.Data.OleDb/tests/OleDbCommandBuilderTests.cs @@ -162,8 +162,12 @@ Lastname NVARCHAR(40), catch (SEHException sehEx) { Console.WriteLine($"Code: {sehEx.ErrorCode}"); - Console.WriteLine($"Base Exception error code : {sehEx.GetBaseException().HResult}"); - Console.WriteLine($"Base Exception message : {sehEx.GetBaseException()?.ToString()}"); + Exception baseException = sehEx.GetBaseException(); + if (baseException != null) + { + Console.WriteLine($"Base Exception error code : {baseException.HResult}"); + Console.WriteLine($"Base Exception message : {baseException.ToString()}"); + } Console.WriteLine($"Base Inner Exception: {sehEx.InnerException}"); // This exception is not expected. So rethrow to indicate test failure. From 1a8aa774a43d26e1b1746e4af91614a73e7a5856 Mon Sep 17 00:00:00 2001 From: Maryam Ariyan Date: Tue, 4 Jun 2019 07:36:59 -0700 Subject: [PATCH 08/13] Apply nit feedback --- src/System.Data.OleDb/tests/Helpers.cs | 6 +++--- src/System.Data.OleDb/tests/OleDbCommandBuilderTests.cs | 9 ++++----- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/src/System.Data.OleDb/tests/Helpers.cs b/src/System.Data.OleDb/tests/Helpers.cs index 2862aef062ae..66d289c911a6 100644 --- a/src/System.Data.OleDb/tests/Helpers.cs +++ b/src/System.Data.OleDb/tests/Helpers.cs @@ -20,7 +20,7 @@ private class Nested public static readonly string ProviderName; public static Nested Instance => s_instance; private static readonly Nested s_instance = new Nested(); - private static readonly string s_expectedProviderName = @"Microsoft.ACE.OLEDB.12.0"; + private const string ExpectedProviderName = @"Microsoft.ACE.OLEDB.12.0"; private Nested() { } static Nested() { @@ -38,8 +38,8 @@ static Nested() } // skip if x86 or if both drivers available IsAvailable = !PlatformDetection.Is32BitProcess && - !(jetDriverInstalled && providerNames.Contains(s_expectedProviderName)); - ProviderName = IsAvailable ? s_expectedProviderName : null; + !(jetDriverInstalled && providerNames.Contains(ExpectedProviderName)); + ProviderName = IsAvailable ? ExpectedProviderName : null; } } } diff --git a/src/System.Data.OleDb/tests/OleDbCommandBuilderTests.cs b/src/System.Data.OleDb/tests/OleDbCommandBuilderTests.cs index 917bf487366e..00c04829ef01 100644 --- a/src/System.Data.OleDb/tests/OleDbCommandBuilderTests.cs +++ b/src/System.Data.OleDb/tests/OleDbCommandBuilderTests.cs @@ -2,6 +2,7 @@ // 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.Diagnostics; using System.IO; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; @@ -163,11 +164,9 @@ Lastname NVARCHAR(40), { Console.WriteLine($"Code: {sehEx.ErrorCode}"); Exception baseException = sehEx.GetBaseException(); - if (baseException != null) - { - Console.WriteLine($"Base Exception error code : {baseException.HResult}"); - Console.WriteLine($"Base Exception message : {baseException.ToString()}"); - } + Debug.Assert(baseException != null); + Console.WriteLine($"Base Exception error code : {baseException.HResult}"); + Console.WriteLine($"Base Exception message : {baseException}"); Console.WriteLine($"Base Inner Exception: {sehEx.InnerException}"); // This exception is not expected. So rethrow to indicate test failure. From 9f94ec78d1052086b6b3b96c974cbc44ec866496 Mon Sep 17 00:00:00 2001 From: Maryam Ariyan Date: Mon, 17 Jun 2019 10:49:48 -0700 Subject: [PATCH 09/13] Skip if x86 or if the expected driver not available --- src/System.Data.OleDb/tests/Helpers.cs | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/src/System.Data.OleDb/tests/Helpers.cs b/src/System.Data.OleDb/tests/Helpers.cs index 66d289c911a6..b021a462192c 100644 --- a/src/System.Data.OleDb/tests/Helpers.cs +++ b/src/System.Data.OleDb/tests/Helpers.cs @@ -24,21 +24,16 @@ private class Nested private Nested() { } static Nested() { - bool jetDriverInstalled = false; // Get the sources rowset for the SQLOLEDB enumerator DataTable table = (new OleDbEnumerator()).GetElements(); DataColumn providersRegistered = table.Columns["SOURCES_NAME"]; List providerNames = new List(); foreach (DataRow row in table.Rows) { - var curProvider = (string)row[providersRegistered]; - if (curProvider.Contains("JET")) - jetDriverInstalled = true; - providerNames.Add(curProvider); + providerNames.Add((string)row[providersRegistered]); } - // skip if x86 or if both drivers available - IsAvailable = !PlatformDetection.Is32BitProcess && - !(jetDriverInstalled && providerNames.Contains(ExpectedProviderName)); + // skip if x86 or if the expected driver not available + IsAvailable = !PlatformDetection.Is32BitProcess && providerNames.Contains(ExpectedProviderName); ProviderName = IsAvailable ? ExpectedProviderName : null; } } From e1cc57595fd4777f9b821c33adf91c36b17fe59a Mon Sep 17 00:00:00 2001 From: Maryam Ariyan Date: Fri, 28 Jun 2019 13:02:35 -0700 Subject: [PATCH 10/13] Skip for non en-US culture --- src/System.Data.OleDb/tests/Helpers.cs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/System.Data.OleDb/tests/Helpers.cs b/src/System.Data.OleDb/tests/Helpers.cs index b021a462192c..b4755406d186 100644 --- a/src/System.Data.OleDb/tests/Helpers.cs +++ b/src/System.Data.OleDb/tests/Helpers.cs @@ -2,6 +2,7 @@ // See the LICENSE file in the project root for more information. using System.Collections.Generic; +using System.Globalization; namespace System.Data.OleDb.Tests { @@ -34,6 +35,10 @@ static Nested() } // skip if x86 or if the expected driver not available IsAvailable = !PlatformDetection.Is32BitProcess && providerNames.Contains(ExpectedProviderName); + if (!CultureInfo.CurrentCulture.Name.Equals("en-US", StringComparison.OrdinalIgnoreCase)) + { + IsAvailable = false; // ActiveIssue: https://github.com/dotnet/corefx/issues/38737 + } ProviderName = IsAvailable ? ExpectedProviderName : null; } } From 11eff89a3dbcf2cb2d6172165e3331258a30908b Mon Sep 17 00:00:00 2001 From: Maryam Ariyan Date: Wed, 3 Jul 2019 10:47:34 -0700 Subject: [PATCH 11/13] expected as first arg to Assert.Equal + rename --- .../System/AssertExtensions.cs | 22 +++++++++---------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/src/Common/tests/CoreFx.Private.TestUtilities/System/AssertExtensions.cs b/src/Common/tests/CoreFx.Private.TestUtilities/System/AssertExtensions.cs index f09b4ee68e3a..dec6f7af745e 100644 --- a/src/Common/tests/CoreFx.Private.TestUtilities/System/AssertExtensions.cs +++ b/src/Common/tests/CoreFx.Private.TestUtilities/System/AssertExtensions.cs @@ -15,10 +15,10 @@ public static class AssertExtensions { private static bool IsFullFramework => RuntimeInformation.FrameworkDescription.StartsWith(".NET Framework"); - public static void Throws(Action action, string message) + public static void Throws(Action action, string expectedMessage) where T : Exception { - Assert.Equal(Assert.Throws(action).Message, message); + Assert.Equal(expectedMessage, Assert.Throws(action).Message); } public static void Throws(string netCoreParamName, string netFxParamName, Action action) @@ -57,12 +57,12 @@ public static void Throws(string netCoreParamName, string netFxParamName, Fun Assert.Equal(expectedParamName, exception.ParamName); } - public static T Throws(string paramName, Action action) + public static T Throws(string expectedParamName, Action action) where T : ArgumentException { T exception = Assert.Throws(action); - Assert.Equal(paramName, exception.ParamName); + Assert.Equal(expectedParamName, exception.ParamName); return exception; } @@ -75,27 +75,27 @@ public static T Throws(Action action) return exception; } - public static T Throws(string paramName, Func testCode) + public static T Throws(string expectedParamName, Func testCode) where T : ArgumentException { T exception = Assert.Throws(testCode); - Assert.Equal(paramName, exception.ParamName); + Assert.Equal(expectedParamName, exception.ParamName); return exception; } - public static async Task ThrowsAsync(string paramName, Func testCode) + public static async Task ThrowsAsync(string expectedParamName, Func testCode) where T : ArgumentException { T exception = await Assert.ThrowsAsync(testCode); - Assert.Equal(paramName, exception.ParamName); + Assert.Equal(expectedParamName, exception.ParamName); return exception; } - public static void Throws(string paramName, Action action) + public static void Throws(string expectedParamName, Action action) where TNetCoreExceptionType : ArgumentException where TNetFxExceptionType : Exception { @@ -106,7 +106,7 @@ public static void Throws(string par if (typeof(ArgumentException).IsAssignableFrom(typeof(TNetFxExceptionType))) { Exception exception = Assert.Throws(typeof(TNetFxExceptionType), action); - Assert.Equal(paramName, ((ArgumentException)exception).ParamName); + Assert.Equal(expectedParamName, ((ArgumentException)exception).ParamName); } else { @@ -115,7 +115,7 @@ public static void Throws(string par } else { - AssertExtensions.Throws(paramName, action); + AssertExtensions.Throws(expectedParamName, action); } } From a535e616725734a77c81eef6a10b382806e3bcdc Mon Sep 17 00:00:00 2001 From: Maryam Ariyan Date: Wed, 3 Jul 2019 11:29:30 -0700 Subject: [PATCH 12/13] Fix tests --- src/System.Data.OleDb/tests/OleDbCommandBuilderTests.cs | 4 ++-- src/System.Data.OleDb/tests/OleDbCommandTests.cs | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/System.Data.OleDb/tests/OleDbCommandBuilderTests.cs b/src/System.Data.OleDb/tests/OleDbCommandBuilderTests.cs index 00c04829ef01..1f40ba196a81 100644 --- a/src/System.Data.OleDb/tests/OleDbCommandBuilderTests.cs +++ b/src/System.Data.OleDb/tests/OleDbCommandBuilderTests.cs @@ -94,11 +94,11 @@ public void QuoteUnquoteIdentifier_Null_Throws() { AssertExtensions.Throws( () => builder.QuoteIdentifier(null, command.Connection), - $"Value cannot be null.\r\nParameter name: unquotedIdentifier"); + $"Value cannot be null. (Parameter \'unquotedIdentifier\')"); AssertExtensions.Throws( () => builder.UnquoteIdentifier(null, command.Connection), - $"Value cannot be null.\r\nParameter name: quotedIdentifier"); + $"Value cannot be null. (Parameter \'quotedIdentifier\')"); } command.CommandType = CommandType.Text; }); diff --git a/src/System.Data.OleDb/tests/OleDbCommandTests.cs b/src/System.Data.OleDb/tests/OleDbCommandTests.cs index 4493ec09b009..833f76f2c777 100644 --- a/src/System.Data.OleDb/tests/OleDbCommandTests.cs +++ b/src/System.Data.OleDb/tests/OleDbCommandTests.cs @@ -23,7 +23,7 @@ public void UpdatedRowSource_SetInvalidValue_Throws() Assert.Equal(UpdateRowSource.FirstReturnedRecord, cmd.UpdatedRowSource); AssertExtensions.Throws( () => cmd.UpdatedRowSource = (UpdateRowSource)InvalidValue, - $"The {nameof(UpdateRowSource)} enumeration value, {InvalidValue}, is invalid.\r\nParameter name: {nameof(UpdateRowSource)}" + $"The {nameof(UpdateRowSource)} enumeration value, {InvalidValue}, is invalid. (Parameter \'{nameof(UpdateRowSource)}\')" ); } } @@ -36,7 +36,7 @@ public void CommandTimeout_SetInvalidValue_Throws() { AssertExtensions.Throws( () => cmd.CommandTimeout = InvalidValue, - $"Invalid CommandTimeout value {InvalidValue}; the value must be >= 0.\r\nParameter name: {nameof(cmd.CommandTimeout)}" + $"Invalid CommandTimeout value {InvalidValue}; the value must be >= 0. (Parameter \'{nameof(cmd.CommandTimeout)}\')" ); } } @@ -63,7 +63,7 @@ public void CommandType_SetInvalidValue_Throws() { AssertExtensions.Throws( () => cmd.CommandType = (CommandType)InvalidValue, - $"The CommandType enumeration value, {InvalidValue}, is invalid.\r\nParameter name: {nameof(cmd.CommandType)}" + $"The CommandType enumeration value, {InvalidValue}, is invalid. (Parameter \'{nameof(cmd.CommandType)}\')" ); } } @@ -151,7 +151,7 @@ public void Parameters_AddNullParameter_Throws() RunTest((command, tableName) => { AssertExtensions.Throws( () => command.Parameters.Add(null), - $"The {nameof(OleDbParameterCollection)} only accepts non-null {nameof(OleDbParameter)} type objects.\r\nParameter name: value" + $"The {nameof(OleDbParameterCollection)} only accepts non-null {nameof(OleDbParameter)} type objects. (Parameter \'value\')" ); command.CommandText = "SELECT * FROM " + tableName + " WHERE NumPlants = ?"; command.Parameters.Add(new OleDbParameter("@p1", 7)); From cc2fd58584c10d5c27246f25b95050d4ae10cce2 Mon Sep 17 00:00:00 2001 From: Maryam Ariyan Date: Wed, 3 Jul 2019 12:00:03 -0700 Subject: [PATCH 13/13] Fix test + Keep expected as before for netfx --- .../tests/OleDbCommandBuilderTests.cs | 27 +++++-- .../tests/OleDbCommandTests.cs | 72 ++++++++++++++----- .../tests/SignedCms/CmsSignerTests.cs | 2 +- 3 files changed, 77 insertions(+), 24 deletions(-) diff --git a/src/System.Data.OleDb/tests/OleDbCommandBuilderTests.cs b/src/System.Data.OleDb/tests/OleDbCommandBuilderTests.cs index 1f40ba196a81..52f81fa30245 100644 --- a/src/System.Data.OleDb/tests/OleDbCommandBuilderTests.cs +++ b/src/System.Data.OleDb/tests/OleDbCommandBuilderTests.cs @@ -92,13 +92,26 @@ public void QuoteUnquoteIdentifier_Null_Throws() command.CommandText = @"SELECT * FROM " + tableName; using (var builder = (OleDbCommandBuilder)OleDbFactory.Instance.CreateCommandBuilder()) { - AssertExtensions.Throws( - () => builder.QuoteIdentifier(null, command.Connection), - $"Value cannot be null. (Parameter \'unquotedIdentifier\')"); - - AssertExtensions.Throws( - () => builder.UnquoteIdentifier(null, command.Connection), - $"Value cannot be null. (Parameter \'quotedIdentifier\')"); + if (PlatformDetection.IsFullFramework) + { + AssertExtensions.Throws( + () => builder.QuoteIdentifier(null, command.Connection), + $"Value cannot be null.\r\nParameter name: unquotedIdentifier"); + + AssertExtensions.Throws( + () => builder.UnquoteIdentifier(null, command.Connection), + $"Value cannot be null.\r\nParameter name: quotedIdentifier"); + } + else + { + AssertExtensions.Throws( + () => builder.QuoteIdentifier(null, command.Connection), + $"Value cannot be null. (Parameter \'unquotedIdentifier\')"); + + AssertExtensions.Throws( + () => builder.UnquoteIdentifier(null, command.Connection), + $"Value cannot be null. (Parameter \'quotedIdentifier\')"); + } } command.CommandType = CommandType.Text; }); diff --git a/src/System.Data.OleDb/tests/OleDbCommandTests.cs b/src/System.Data.OleDb/tests/OleDbCommandTests.cs index 833f76f2c777..ebc6e95eb14a 100644 --- a/src/System.Data.OleDb/tests/OleDbCommandTests.cs +++ b/src/System.Data.OleDb/tests/OleDbCommandTests.cs @@ -21,10 +21,20 @@ public void UpdatedRowSource_SetInvalidValue_Throws() Assert.Equal(UpdateRowSource.Both, cmd.UpdatedRowSource); cmd.UpdatedRowSource = UpdateRowSource.FirstReturnedRecord; Assert.Equal(UpdateRowSource.FirstReturnedRecord, cmd.UpdatedRowSource); - AssertExtensions.Throws( - () => cmd.UpdatedRowSource = (UpdateRowSource)InvalidValue, - $"The {nameof(UpdateRowSource)} enumeration value, {InvalidValue}, is invalid. (Parameter \'{nameof(UpdateRowSource)}\')" - ); + if (PlatformDetection.IsFullFramework) + { + AssertExtensions.Throws( + () => cmd.UpdatedRowSource = (UpdateRowSource)InvalidValue, + $"The {nameof(UpdateRowSource)} enumeration value, {InvalidValue}, is invalid.\r\nParameter name: {nameof(UpdateRowSource)}" + ); + } + else + { + AssertExtensions.Throws( + () => cmd.UpdatedRowSource = (UpdateRowSource)InvalidValue, + $"The {nameof(UpdateRowSource)} enumeration value, {InvalidValue}, is invalid. (Parameter \'{nameof(UpdateRowSource)}\')" + ); + } } } @@ -34,10 +44,20 @@ public void CommandTimeout_SetInvalidValue_Throws() const int InvalidValue = -1; using (var cmd = new OleDbCommand(default, connection, transaction)) { - AssertExtensions.Throws( - () => cmd.CommandTimeout = InvalidValue, - $"Invalid CommandTimeout value {InvalidValue}; the value must be >= 0. (Parameter \'{nameof(cmd.CommandTimeout)}\')" - ); + if (PlatformDetection.IsFullFramework) + { + AssertExtensions.Throws( + () => cmd.CommandTimeout = InvalidValue, + $"Invalid CommandTimeout value {InvalidValue}; the value must be >= 0.\r\nParameter name: {nameof(cmd.CommandTimeout)}" + ); + } + else + { + AssertExtensions.Throws( + () => cmd.CommandTimeout = InvalidValue, + $"Invalid CommandTimeout value {InvalidValue}; the value must be >= 0. (Parameter \'{nameof(cmd.CommandTimeout)}\')" + ); + } } } @@ -61,10 +81,20 @@ public void CommandType_SetInvalidValue_Throws() const int InvalidValue = 0; using (var cmd = (OleDbCommand)OleDbFactory.Instance.CreateCommand()) { - AssertExtensions.Throws( - () => cmd.CommandType = (CommandType)InvalidValue, - $"The CommandType enumeration value, {InvalidValue}, is invalid. (Parameter \'{nameof(cmd.CommandType)}\')" - ); + if (PlatformDetection.IsFullFramework) + { + AssertExtensions.Throws( + () => cmd.CommandType = (CommandType)InvalidValue, + $"The CommandType enumeration value, {InvalidValue}, is invalid.\r\nParameter name: {nameof(cmd.CommandType)}" + ); + } + else + { + AssertExtensions.Throws( + () => cmd.CommandType = (CommandType)InvalidValue, + $"The CommandType enumeration value, {InvalidValue}, is invalid. (Parameter \'{nameof(cmd.CommandType)}\')" + ); + } } } @@ -149,10 +179,20 @@ public void Prepare_InsertMultipleItems_UseTableDirectToVerify() public void Parameters_AddNullParameter_Throws() { RunTest((command, tableName) => { - AssertExtensions.Throws( - () => command.Parameters.Add(null), - $"The {nameof(OleDbParameterCollection)} only accepts non-null {nameof(OleDbParameter)} type objects. (Parameter \'value\')" - ); + if (PlatformDetection.IsFullFramework) + { + AssertExtensions.Throws( + () => command.Parameters.Add(null), + $"The {nameof(OleDbParameterCollection)} only accepts non-null {nameof(OleDbParameter)} type objects.\r\nParameter name: value" + ); + } + else + { + AssertExtensions.Throws( + () => command.Parameters.Add(null), + $"The {nameof(OleDbParameterCollection)} only accepts non-null {nameof(OleDbParameter)} type objects. (Parameter \'value\')" + ); + } command.CommandText = "SELECT * FROM " + tableName + " WHERE NumPlants = ?"; command.Parameters.Add(new OleDbParameter("@p1", 7)); using (OleDbDataReader reader = command.ExecuteReader()) diff --git a/src/System.Security.Cryptography.Pkcs/tests/SignedCms/CmsSignerTests.cs b/src/System.Security.Cryptography.Pkcs/tests/SignedCms/CmsSignerTests.cs index 90f617994b55..9893cf2853f1 100644 --- a/src/System.Security.Cryptography.Pkcs/tests/SignedCms/CmsSignerTests.cs +++ b/src/System.Security.Cryptography.Pkcs/tests/SignedCms/CmsSignerTests.cs @@ -17,7 +17,7 @@ public static void SignerIdentifierType_InvalidValues(SubjectIdentifierType inva CmsSigner signer = new CmsSigner(); AssertExtensions.Throws( - paramName: null, + expectedParamName: null, () => signer.SignerIdentifierType = invalidType); } }