Browse Source

[corlib/System.Data] Test fixes for xammac 4.5 and watchos

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.
Alexander Köplinger 8 years ago
parent
commit
ceabda8a54

+ 8 - 0
mcs/class/System.Data/Test/ProviderTests/System.Data.SqlClient/SqlParameterCollectionTest.cs

@@ -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 ()
 		{

+ 5 - 2
mcs/class/corlib/Test/System/TimeZoneInfoTest.cs

@@ -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