Skip to content

Commit

Permalink
Fixed netfx System.Data.Common.Tests fails on non English Windows (do…
Browse files Browse the repository at this point in the history
…tnet/corefx#28181)

* Fixed netfx System.Data.Common.Tests fails on non English Windows

* Added Comments


Commit migrated from dotnet/corefx@943e316
  • Loading branch information
AlexRadch authored and saurabh500 committed Apr 10, 2018
1 parent 3e2edd6 commit 3d6108f
Show file tree
Hide file tree
Showing 6 changed files with 148 additions and 40 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
using System.Collections.Generic;
using System.Data.Common;
using System.Text;
using System.Text.RegularExpressions;

using Xunit;

Expand Down Expand Up @@ -319,7 +320,12 @@ public void Indexer_Keyword_Invalid()
Assert.Equal(typeof(ArgumentException), ex.GetType());
Assert.Null(ex.InnerException);
Assert.NotNull(ex.Message);
Assert.True(ex.Message.IndexOf("'" + keyword + "'") != -1);

// \p{Pi} any kind of opening quote https://www.compart.com/en/unicode/category/Pi
// \p{Pf} any kind of closing quote https://www.compart.com/en/unicode/category/Pf
// \p{Po} any kind of punctuation character that is not a dash, bracket, quote or connector https://www.compart.com/en/unicode/category/Po
Assert.Matches(@"[\p{Pi}\p{Po}]" + Regex.Escape(keyword) + @"[\p{Pf}\p{Po}]", ex.Message);

Assert.Null(ex.ParamName);
}
}
Expand All @@ -339,7 +345,12 @@ public void Indexer_Keyword_NotSupported()
Assert.Equal(typeof(ArgumentException), ex.GetType());
Assert.Null(ex.InnerException);
Assert.NotNull(ex.Message);
Assert.True(ex.Message.IndexOf("'abc'") != -1);

// \p{Pi} any kind of opening quote https://www.compart.com/en/unicode/category/Pi
// \p{Pf} any kind of closing quote https://www.compart.com/en/unicode/category/Pf
// \p{Po} any kind of punctuation character that is not a dash, bracket, quote or connector https://www.compart.com/en/unicode/category/Po
Assert.Matches(@"[\p{Pi}\p{Po}]" + "abc" + @"[\p{Pf}\p{Po}]", ex.Message);

Assert.Null(ex.ParamName);
}
}
Expand Down Expand Up @@ -403,7 +414,12 @@ public void Indexer_Value_Null()
Assert.Equal(typeof(ArgumentException), ex.GetType());
Assert.Null(ex.InnerException);
Assert.NotNull(ex.Message);
Assert.True(ex.Message.IndexOf("'DriverID'") != -1);

// \p{Pi} any kind of opening quote https://www.compart.com/en/unicode/category/Pi
// \p{Pf} any kind of closing quote https://www.compart.com/en/unicode/category/Pf
// \p{Po} any kind of punctuation character that is not a dash, bracket, quote or connector https://www.compart.com/en/unicode/category/Po
Assert.Matches(@"[\p{Pi}\p{Po}]" + "DriverID" + @"[\p{Pf}\p{Po}]", ex.Message);

Assert.Null(ex.ParamName);
}
Assert.False(_builder.ContainsKey("DriverID"));
Expand Down
104 changes: 78 additions & 26 deletions src/libraries/System.Data.Common/tests/System/Data/DataRowTest2.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
using System.Collections;
using System.Globalization;
using System.IO;

using System.Text.RegularExpressions;


using Xunit;
Expand Down Expand Up @@ -1048,8 +1048,12 @@ public void Indexer1_Column_NotInTable()
Assert.Equal(typeof(ArgumentException), ex.GetType());
Assert.Null(ex.InnerException);
Assert.NotNull(ex.Message);
Assert.True(ex.Message.IndexOf("'Col0'") != -1);
Assert.True(ex.Message.IndexOf("TableA") != -1);

// \p{Pi} any kind of opening quote https://www.compart.com/en/unicode/category/Pi
// \p{Pf} any kind of closing quote https://www.compart.com/en/unicode/category/Pf
// \p{Po} any kind of punctuation character that is not a dash, bracket, quote or connector https://www.compart.com/en/unicode/category/Po
Assert.Matches(@"[\p{Pi}\p{Po}]" + "Col0" + @"[\p{Pf}\p{Po}]", ex.Message);
Assert.Matches(@"\b" + "TableA" + @"\b", ex.Message);
}

try
Expand All @@ -1063,8 +1067,12 @@ public void Indexer1_Column_NotInTable()
Assert.Equal(typeof(ArgumentException), ex.GetType());
Assert.Null(ex.InnerException);
Assert.NotNull(ex.Message);
Assert.True(ex.Message.IndexOf("'ZZZ'") != -1);
Assert.True(ex.Message.IndexOf("TableA") != -1);

// \p{Pi} any kind of opening quote https://www.compart.com/en/unicode/category/Pi
// \p{Pf} any kind of closing quote https://www.compart.com/en/unicode/category/Pf
// \p{Po} any kind of punctuation character that is not a dash, bracket, quote or connector https://www.compart.com/en/unicode/category/Po
Assert.Matches(@"[\p{Pi}\p{Po}]" + "ZZZ" + @"[\p{Pf}\p{Po}]", ex.Message);
Assert.Matches(@"\b" + "TableA" + @"\b", ex.Message);
}

dtA.Columns.Remove(dcA2);
Expand All @@ -1080,8 +1088,12 @@ public void Indexer1_Column_NotInTable()
Assert.Equal(typeof(ArgumentException), ex.GetType());
Assert.Null(ex.InnerException);
Assert.NotNull(ex.Message);
Assert.True(ex.Message.IndexOf("'Col1'") != -1);
Assert.True(ex.Message.IndexOf("TableA") != -1);

// \p{Pi} any kind of opening quote https://www.compart.com/en/unicode/category/Pi
// \p{Pf} any kind of closing quote https://www.compart.com/en/unicode/category/Pf
// \p{Po} any kind of punctuation character that is not a dash, bracket, quote or connector https://www.compart.com/en/unicode/category/Po
Assert.Matches(@"[\p{Pi}\p{Po}]" + "Col1" + @"[\p{Pf}\p{Po}]", ex.Message);
Assert.Matches(@"\b" + "TableA" + @"\b", ex.Message);
}
}

Expand Down Expand Up @@ -1177,8 +1189,12 @@ public void Indexer1_Value_Null()
Assert.Equal(typeof(ArgumentException), ex.GetType());
Assert.Null(ex.InnerException);
Assert.NotNull(ex.Message);
Assert.True(ex.Message.IndexOf("'Col0'") != -1);
Assert.True(ex.Message.IndexOf("DBNull") != -1);

// \p{Pi} any kind of opening quote https://www.compart.com/en/unicode/category/Pi
// \p{Pf} any kind of closing quote https://www.compart.com/en/unicode/category/Pf
// \p{Po} any kind of punctuation character that is not a dash, bracket, quote or connector https://www.compart.com/en/unicode/category/Po
Assert.Matches(@"[\p{Pi}\p{Po}]" + "Col0" + @"[\p{Pf}\p{Po}]", ex.Message);
Assert.Matches(@"\b" + "DBNull" + @"\b", ex.Message);
}

Assert.Equal(1, _eventsFired.Count);
Expand Down Expand Up @@ -1427,8 +1443,12 @@ public void Indexer2_Value_Null()
Assert.Equal(typeof(ArgumentException), ex.GetType());
Assert.Null(ex.InnerException);
Assert.NotNull(ex.Message);
Assert.True(ex.Message.IndexOf("'Col0'") != -1);
Assert.True(ex.Message.IndexOf("DBNull") != -1);

// \p{Pi} any kind of opening quote https://www.compart.com/en/unicode/category/Pi
// \p{Pf} any kind of closing quote https://www.compart.com/en/unicode/category/Pf
// \p{Po} any kind of punctuation character that is not a dash, bracket, quote or connector https://www.compart.com/en/unicode/category/Po
Assert.Matches(@"[\p{Pi}\p{Po}]" + "Col0" + @"[\p{Pf}\p{Po}]", ex.Message);
Assert.Matches(@"\b" + "DBNull" + @"\b", ex.Message);
}

Assert.Equal(addressA, dr[0]);
Expand Down Expand Up @@ -1550,8 +1570,13 @@ public void Indexer3_ColumnName_Empty()
Assert.Equal(typeof(ArgumentException), ex.GetType());
Assert.Null(ex.InnerException);
Assert.NotNull(ex.Message);
Assert.True(ex.Message.IndexOf("''") != -1);
Assert.True(ex.Message.IndexOf("Persons") != -1);

// \p{Pi} any kind of opening quote https://www.compart.com/en/unicode/category/Pi
// \p{Pf} any kind of closing quote https://www.compart.com/en/unicode/category/Pf
// \p{Po} any kind of punctuation character that is not a dash, bracket, quote or connector https://www.compart.com/en/unicode/category/Po
Assert.Matches(@"[\p{Pi}\p{Po}]" + "" + @"[\p{Pf}\p{Po}]", ex.Message);
Assert.Matches(@"\b" + "Persons" + @"\b", ex.Message);

Assert.Null(ex.ParamName);
}

Expand All @@ -1566,8 +1591,13 @@ public void Indexer3_ColumnName_Empty()
Assert.Equal(typeof(ArgumentException), ex.GetType());
Assert.Null(ex.InnerException);
Assert.NotNull(ex.Message);
Assert.True(ex.Message.IndexOf("''") != -1);
Assert.True(ex.Message.IndexOf("Persons") != -1);

// \p{Pi} any kind of opening quote https://www.compart.com/en/unicode/category/Pi
// \p{Pf} any kind of closing quote https://www.compart.com/en/unicode/category/Pf
// \p{Po} any kind of punctuation character that is not a dash, bracket, quote or connector https://www.compart.com/en/unicode/category/Po
Assert.Matches(@"[\p{Pi}\p{Po}]" + "" + @"[\p{Pf}\p{Po}]", ex.Message);
Assert.Matches(@"\b" + "Persons" + @"\b", ex.Message);

Assert.Null(ex.ParamName);
}
}
Expand Down Expand Up @@ -1649,8 +1679,12 @@ public void Indexer3_Value_Null()
Assert.Equal(typeof(ArgumentException), ex.GetType());
Assert.Null(ex.InnerException);
Assert.NotNull(ex.Message);
Assert.True(ex.Message.IndexOf("'Col0'") != -1);
Assert.True(ex.Message.IndexOf("DBNull") != -1);

// \p{Pi} any kind of opening quote https://www.compart.com/en/unicode/category/Pi
// \p{Pf} any kind of closing quote https://www.compart.com/en/unicode/category/Pf
// \p{Po} any kind of punctuation character that is not a dash, bracket, quote or connector https://www.compart.com/en/unicode/category/Po
Assert.Matches(@"[\p{Pi}\p{Po}]" + "Col0" + @"[\p{Pf}\p{Po}]", ex.Message);
Assert.Matches(@"\b" + "DBNull" + @"\b", ex.Message);
}

Assert.Equal(addressA, dr["Col0"]);
Expand Down Expand Up @@ -1823,8 +1857,12 @@ public void Indexer4_Column_NotInTable()
Assert.Equal(typeof(ArgumentException), ex.GetType());
Assert.Null(ex.InnerException);
Assert.NotNull(ex.Message);
Assert.True(ex.Message.IndexOf("'Col0'") != -1);
Assert.True(ex.Message.IndexOf("TableA") != -1);

// \p{Pi} any kind of opening quote https://www.compart.com/en/unicode/category/Pi
// \p{Pf} any kind of closing quote https://www.compart.com/en/unicode/category/Pf
// \p{Po} any kind of punctuation character that is not a dash, bracket, quote or connector https://www.compart.com/en/unicode/category/Po
Assert.Matches(@"[\p{Pi}\p{Po}]" + "Col0" + @"[\p{Pf}\p{Po}]", ex.Message);
Assert.Matches(@"\b" + "TableA" + @"\b", ex.Message);
}

try
Expand All @@ -1838,8 +1876,12 @@ public void Indexer4_Column_NotInTable()
Assert.Equal(typeof(ArgumentException), ex.GetType());
Assert.Null(ex.InnerException);
Assert.NotNull(ex.Message);
Assert.True(ex.Message.IndexOf("'ZZZ'") != -1);
Assert.True(ex.Message.IndexOf("TableA") != -1);

// \p{Pi} any kind of opening quote https://www.compart.com/en/unicode/category/Pi
// \p{Pf} any kind of closing quote https://www.compart.com/en/unicode/category/Pf
// \p{Po} any kind of punctuation character that is not a dash, bracket, quote or connector https://www.compart.com/en/unicode/category/Po
Assert.Matches(@"[\p{Pi}\p{Po}]" + "ZZZ" + @"[\p{Pf}\p{Po}]", ex.Message);
Assert.Matches(@"\b" + "TableA" + @"\b", ex.Message);
}

dtA.Columns.Remove(dcA2);
Expand All @@ -1855,8 +1897,12 @@ public void Indexer4_Column_NotInTable()
Assert.Equal(typeof(ArgumentException), ex.GetType());
Assert.Null(ex.InnerException);
Assert.NotNull(ex.Message);
Assert.True(ex.Message.IndexOf("'Col1'") != -1);
Assert.True(ex.Message.IndexOf("TableA") != -1);

// \p{Pi} any kind of opening quote https://www.compart.com/en/unicode/category/Pi
// \p{Pf} any kind of closing quote https://www.compart.com/en/unicode/category/Pf
// \p{Po} any kind of punctuation character that is not a dash, bracket, quote or connector https://www.compart.com/en/unicode/category/Po
Assert.Matches(@"[\p{Pi}\p{Po}]" + "Col1" + @"[\p{Pf}\p{Po}]", ex.Message);
Assert.Matches(@"\b" + "TableA" + @"\b", ex.Message);
}
}

Expand Down Expand Up @@ -2524,9 +2570,15 @@ public void TestRowErrors()
DataRow[] rows = table.GetErrors();

Assert.Equal(2, rows.Length);
Assert.Equal("Column 'col1' does not allow DBNull.Value.", table.Rows[0].RowError);
Assert.Equal("Column 'col2, col3' is constrained to be unique. Value '1, 1' is already present."
, table.Rows[1].RowError);

// \p{Pi} any kind of opening quote https://www.compart.com/en/unicode/category/Pi
// \p{Pf} any kind of closing quote https://www.compart.com/en/unicode/category/Pf
// \p{Po} any kind of punctuation character that is not a dash, bracket, quote or connector https://www.compart.com/en/unicode/category/Po
Assert.Matches(@"[\p{Pi}\p{Po}]" + "col1" + @"[\p{Pf}\p{Po}]", table.Rows[0].RowError);
Assert.Matches(@"\b" + Regex.Escape("DBNull.Value") + @"\b", table.Rows[0].RowError);

Assert.Matches(@"[\p{Pi}\p{Po}]" + "col2" + @"\p{Po}\s*" + "col3" + @"[\p{Pf}\p{Po}]", table.Rows[1].RowError);
Assert.Matches(@"[\p{Pi}\p{Po}]" + "1" + @"\p{Po}\s*" + "1" + @"[\p{Pf}\p{Po}]", table.Rows[1].RowError);

Assert.Equal(table.Rows[0].RowError, table.Rows[0].GetColumnError(0));
Assert.Equal(table.Rows[1].RowError, table.Rows[0].GetColumnError(1));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
using System.IO;
using System.Runtime.Serialization.Formatters.Binary;
using System.Runtime.Serialization.Formatters.Tests;
using System.Text.RegularExpressions;
using System.Xml;
using Xunit;

Expand Down Expand Up @@ -1249,8 +1250,12 @@ public void ImportRowTest()
Assert.Equal(typeof(ConstraintException), ex.GetType());
Assert.Null(ex.InnerException);
Assert.NotNull(ex.Message);
Assert.True(ex.Message.IndexOf("'id'") != -1);
Assert.True(ex.Message.IndexOf("'3'") != -1);

// \p{Pi} any kind of opening quote https://www.compart.com/en/unicode/category/Pi
// \p{Pf} any kind of closing quote https://www.compart.com/en/unicode/category/Pf
// \p{Po} any kind of punctuation character that is not a dash, bracket, quote or connector https://www.compart.com/en/unicode/category/Po
Assert.Matches(@"[\p{Pi}\p{Po}]" + "id" + @"[\p{Pf}\p{Po}]", ex.Message);
Assert.Matches(@"[\p{Pi}\p{Po}]" + "3" + @"[\p{Pf}\p{Po}]", ex.Message);
}

// check row states
Expand Down Expand Up @@ -1353,8 +1358,12 @@ public void ImportRowDeletedTest()
Assert.Equal(typeof(ConstraintException), ex.GetType());
Assert.Null(ex.InnerException);
Assert.NotNull(ex.Message);
Assert.True(ex.Message.IndexOf("'col'") != -1);
Assert.True(ex.Message.IndexOf("'1'") != -1);

// \p{Pi} any kind of opening quote https://www.compart.com/en/unicode/category/Pi
// \p{Pf} any kind of closing quote https://www.compart.com/en/unicode/category/Pf
// \p{Po} any kind of punctuation character that is not a dash, bracket, quote or connector https://www.compart.com/en/unicode/category/Po
Assert.Matches(@"[\p{Pi}\p{Po}]" + "col" + @"[\p{Pf}\p{Po}]", ex.Message);
Assert.Matches(@"[\p{Pi}\p{Po}]" + "1" + @"[\p{Pf}\p{Po}]", ex.Message);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
using System.Collections;
using System.Globalization;
using System.Collections.Generic;

using System.Text.RegularExpressions;


using Xunit;
Expand Down Expand Up @@ -267,7 +267,12 @@ public void Columns()
Assert.Equal(typeof(ArgumentException), ex.GetType());
Assert.Null(ex.InnerException);
Assert.NotNull(ex.Message);
Assert.True(ex.Message.IndexOf("'TEST'") != -1);

// \p{Pi} any kind of opening quote https://www.compart.com/en/unicode/category/Pi
// \p{Pf} any kind of closing quote https://www.compart.com/en/unicode/category/Pf
// \p{Po} any kind of punctuation character that is not a dash, bracket, quote or connector https://www.compart.com/en/unicode/category/Po
Assert.Matches(@"[\p{Pi}\p{Po}]" + "TEST" + @"[\p{Pf}\p{Po}]", ex.Message);

Assert.Null(ex.ParamName);
}
}
Expand Down Expand Up @@ -1640,7 +1645,11 @@ public void BeginLoadData()
Assert.Equal(typeof(NoNullAllowedException), ex.GetType());
Assert.Null(ex.InnerException);
Assert.NotNull(ex.Message);
Assert.True(ex.Message.IndexOf("'ParentId'") != -1);

// \p{Pi} any kind of opening quote https://www.compart.com/en/unicode/category/Pi
// \p{Pf} any kind of closing quote https://www.compart.com/en/unicode/category/Pf
// \p{Po} any kind of punctuation character that is not a dash, bracket, quote or connector https://www.compart.com/en/unicode/category/Po
Assert.Matches(@"[\p{Pi}\p{Po}]" + "ParentId" + @"[\p{Pf}\p{Po}]", ex.Message);
}

DataTable dt1 = DataProvider.CreateUniqueConstraint();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
//

using System.IO;
using System.Text.RegularExpressions;

using Xunit;

Expand Down Expand Up @@ -645,7 +646,12 @@ public void XmlSchemaTest6()
Assert.Equal(typeof(ArgumentException), ex.GetType());
Assert.Null(ex.InnerException);
Assert.NotNull(ex.Message);
Assert.True(ex.Message.IndexOf("'Table1'") != -1);

// \p{Pi} any kind of opening quote https://www.compart.com/en/unicode/category/Pi
// \p{Pf} any kind of closing quote https://www.compart.com/en/unicode/category/Pf
// \p{Po} any kind of punctuation character that is not a dash, bracket, quote or connector https://www.compart.com/en/unicode/category/Po
Assert.Matches(@"[\p{Pi}\p{Po}]" + "Table1" + @"[\p{Pf}\p{Po}]", ex.Message);

Assert.Null(ex.ParamName);
}
}
Expand Down
Loading

0 comments on commit 3d6108f

Please sign in to comment.