Skip to content
This repository was archived by the owner on Jan 23, 2023. It is now read-only.

Commit dd103a8

Browse files
committed
Keep expected as before while running in netfx
1 parent a535e61 commit dd103a8

2 files changed

Lines changed: 76 additions & 23 deletions

File tree

src/System.Data.OleDb/tests/OleDbCommandBuilderTests.cs

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -92,13 +92,26 @@ public void QuoteUnquoteIdentifier_Null_Throws()
9292
command.CommandText = @"SELECT * FROM " + tableName;
9393
using (var builder = (OleDbCommandBuilder)OleDbFactory.Instance.CreateCommandBuilder())
9494
{
95-
AssertExtensions.Throws<ArgumentNullException>(
96-
() => builder.QuoteIdentifier(null, command.Connection),
97-
$"Value cannot be null. (Parameter \'unquotedIdentifier\')");
98-
99-
AssertExtensions.Throws<ArgumentNullException>(
100-
() => builder.UnquoteIdentifier(null, command.Connection),
101-
$"Value cannot be null. (Parameter \'quotedIdentifier\')");
95+
if (PlatformDetection.IsFullFramework)
96+
{
97+
AssertExtensions.Throws<ArgumentNullException>(
98+
() => builder.QuoteIdentifier(null, command.Connection),
99+
$"Value cannot be null.\r\nParameter name: unquotedIdentifier");
100+
101+
AssertExtensions.Throws<ArgumentNullException>(
102+
() => builder.UnquoteIdentifier(null, command.Connection),
103+
$"Value cannot be null.\r\nParameter name: quotedIdentifier");
104+
}
105+
else
106+
{
107+
AssertExtensions.Throws<ArgumentNullException>(
108+
() => builder.QuoteIdentifier(null, command.Connection),
109+
$"Value cannot be null. (Parameter \'unquotedIdentifier\')");
110+
111+
AssertExtensions.Throws<ArgumentNullException>(
112+
() => builder.UnquoteIdentifier(null, command.Connection),
113+
$"Value cannot be null. (Parameter \'quotedIdentifier\')");
114+
}
102115
}
103116
command.CommandType = CommandType.Text;
104117
});

src/System.Data.OleDb/tests/OleDbCommandTests.cs

Lines changed: 56 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,20 @@ public void UpdatedRowSource_SetInvalidValue_Throws()
2121
Assert.Equal(UpdateRowSource.Both, cmd.UpdatedRowSource);
2222
cmd.UpdatedRowSource = UpdateRowSource.FirstReturnedRecord;
2323
Assert.Equal(UpdateRowSource.FirstReturnedRecord, cmd.UpdatedRowSource);
24-
AssertExtensions.Throws<ArgumentOutOfRangeException>(
25-
() => cmd.UpdatedRowSource = (UpdateRowSource)InvalidValue,
26-
$"The {nameof(UpdateRowSource)} enumeration value, {InvalidValue}, is invalid. (Parameter \'{nameof(UpdateRowSource)}\')"
27-
);
24+
if (PlatformDetection.IsFullFramework)
25+
{
26+
AssertExtensions.Throws<ArgumentOutOfRangeException>(
27+
() => cmd.UpdatedRowSource = (UpdateRowSource)InvalidValue,
28+
$"The {nameof(UpdateRowSource)} enumeration value, {InvalidValue}, is invalid.\r\nParameter name: {nameof(UpdateRowSource)}"
29+
);
30+
}
31+
else
32+
{
33+
AssertExtensions.Throws<ArgumentOutOfRangeException>(
34+
() => cmd.UpdatedRowSource = (UpdateRowSource)InvalidValue,
35+
$"The {nameof(UpdateRowSource)} enumeration value, {InvalidValue}, is invalid. (Parameter \'{nameof(UpdateRowSource)}\')"
36+
);
37+
}
2838
}
2939
}
3040

@@ -34,10 +44,20 @@ public void CommandTimeout_SetInvalidValue_Throws()
3444
const int InvalidValue = -1;
3545
using (var cmd = new OleDbCommand(default, connection, transaction))
3646
{
37-
AssertExtensions.Throws<ArgumentException>(
38-
() => cmd.CommandTimeout = InvalidValue,
39-
$"Invalid CommandTimeout value {InvalidValue}; the value must be >= 0. (Parameter \'{nameof(cmd.CommandTimeout)}\')"
40-
);
47+
if (PlatformDetection.IsFullFramework)
48+
{
49+
AssertExtensions.Throws<ArgumentException>(
50+
() => cmd.CommandTimeout = InvalidValue,
51+
$"Invalid CommandTimeout value {InvalidValue}; the value must be >= 0.\r\nParameter name: {nameof(cmd.CommandTimeout)}"
52+
);
53+
}
54+
else
55+
{
56+
AssertExtensions.Throws<ArgumentException>(
57+
() => cmd.CommandTimeout = InvalidValue,
58+
$"Invalid CommandTimeout value {InvalidValue}; the value must be >= 0. (Parameter \'{nameof(cmd.CommandTimeout)}\')"
59+
);
60+
}
4161
}
4262
}
4363

@@ -61,10 +81,20 @@ public void CommandType_SetInvalidValue_Throws()
6181
const int InvalidValue = 0;
6282
using (var cmd = (OleDbCommand)OleDbFactory.Instance.CreateCommand())
6383
{
64-
AssertExtensions.Throws<ArgumentOutOfRangeException>(
65-
() => cmd.CommandType = (CommandType)InvalidValue,
66-
$"The CommandType enumeration value, {InvalidValue}, is invalid. (Parameter \'{nameof(cmd.CommandType)}\')"
67-
);
84+
if (PlatformDetection.IsFullFramework)
85+
{
86+
AssertExtensions.Throws<ArgumentOutOfRangeException>(
87+
() => cmd.CommandType = (CommandType)InvalidValue,
88+
$"The CommandType enumeration value, {InvalidValue}, is invalid.\r\nParameter name: {nameof(cmd.CommandType)}"
89+
);
90+
}
91+
else
92+
{
93+
AssertExtensions.Throws<ArgumentOutOfRangeException>(
94+
() => cmd.CommandType = (CommandType)InvalidValue,
95+
$"The CommandType enumeration value, {InvalidValue}, is invalid. (Parameter \'{nameof(cmd.CommandType)}\')"
96+
);
97+
}
6898
}
6999
}
70100

@@ -149,10 +179,20 @@ public void Prepare_InsertMultipleItems_UseTableDirectToVerify()
149179
public void Parameters_AddNullParameter_Throws()
150180
{
151181
RunTest((command, tableName) => {
152-
AssertExtensions.Throws<ArgumentNullException>(
153-
() => command.Parameters.Add(null),
154-
$"The {nameof(OleDbParameterCollection)} only accepts non-null {nameof(OleDbParameter)} type objects. (Parameter \'value\')"
155-
);
182+
if (PlatformDetection.IsFullFramework)
183+
{
184+
AssertExtensions.Throws<ArgumentNullException>(
185+
() => command.Parameters.Add(null),
186+
$"The {nameof(OleDbParameterCollection)} only accepts non-null {nameof(OleDbParameter)} type objects.\r\nParameter name: value"
187+
);
188+
}
189+
else
190+
{
191+
AssertExtensions.Throws<ArgumentNullException>(
192+
() => command.Parameters.Add(null),
193+
$"The {nameof(OleDbParameterCollection)} only accepts non-null {nameof(OleDbParameter)} type objects. (Parameter \'value\')"
194+
);
195+
}
156196
command.CommandText = "SELECT * FROM " + tableName + " WHERE NumPlants = ?";
157197
command.Parameters.Add(new OleDbParameter("@p1", 7));
158198
using (OleDbDataReader reader = command.ExecuteReader())

0 commit comments

Comments
 (0)