[corlib/System.Data] Test fixes for xammac 4.5 and watchos
authorAlexander Köplinger <alex.koeplinger@outlook.com>
Wed, 19 Apr 2017 19:04:47 +0000 (21:04 +0200)
committerAlexander Köplinger <alex.koeplinger@outlook.com>
Wed, 19 Apr 2017 19:08:52 +0000 (21:08 +0200)
The TrimSpecial() method and Windows-specific code was removed from
xammac 4.5 so reflection can't find it anymore, handle this case.

Also add a workaround for SqlParameterCollectionTest.CopyToTest()
which fails on watchos since the SqlCommand would throw a PNSE.
It's a workaround because it just makes the test ignored since we don't
set the env var that ConnectionManager.Instance.Sql reads in XI tests,
but it makes the test consistent with the other tests in the suite.
We should fix this properly later on.

mcs/class/System.Data/Test/ProviderTests/System.Data.SqlClient/SqlParameterCollectionTest.cs
mcs/class/corlib/Test/System/TimeZoneInfoTest.cs

index ccb6e197d3cd68884cd43f2f96f02e8d73dd7777..48181ca6b1998dff0c744e0ecc0de998acf0033e 100644 (file)
@@ -41,6 +41,14 @@ namespace MonoTests.System.Data.Connected.SqlClient
 
        public class SqlParameterCollectionTest
        {
+               EngineConfig engine;
+
+               [SetUp]
+               public void SetUp ()
+               {
+                       engine = ConnectionManager.Instance.Sql.EngineConfig;
+               }
+
                [Test]
                public void CopyToTest ()
                {
index d25889f6de69f7c78b1f148d45a06107c212ce32..2935c259db2ca9f89688a39eb85be51b3e07f72e 100644 (file)
@@ -867,9 +867,12 @@ namespace MonoTests.System
                        [Test]
                        public void WindowsRegistryTimezoneWithParentheses ()
                        {
-                               var method = (MethodInfo) typeof (TimeZoneInfo).GetMember ("TrimSpecial", MemberTypes.Method, BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic)[0];
+                               var memberInfos = typeof (TimeZoneInfo).GetMember ("TrimSpecial", MemberTypes.Method, BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic);
 
-                               var name = method.Invoke (null, new object [] { " <--->  Central Standard Time (Mexico)   ||<<>>" });
+                               if (memberInfos.Length == 0)
+                                       Assert.Ignore ("TrimSpecial method not found");
+
+                               var name = ((MethodInfo)memberInfos[0]).Invoke (null, new object [] { " <--->  Central Standard Time (Mexico)   ||<<>>" });
                                Assert.AreEqual (name, "Central Standard Time (Mexico)", "#1");
                        }
 #endif