New tests.
[mono.git] / mcs / class / System.Core / Test / System.Linq.Expressions / ExpressionTest_Call.cs
index c5b46d0bf803939e084b34caab803dbdb19e8cc5..8f668d288ab00b6908fd60f63b958e17f153b2f3 100644 (file)
@@ -87,7 +87,11 @@ namespace MonoTests.System.Linq.Expressions {
                }
 
                [Test]
+#if NET_4_0
+               [ExpectedException (typeof (ArgumentException))]
+#else
                [ExpectedException (typeof (ArgumentNullException))]
+#endif
                public void ArgInstanceNullForNonStaticMethod ()
                {
                        Expression.Call (null, typeof (object).GetMethod ("ToString"));
@@ -281,7 +285,7 @@ namespace MonoTests.System.Linq.Expressions {
                {
                        return (int) (i as ConstantExpression).Value;
                }
-
+#if !NET_4_0 // dlr bug 5875
                [Test]
                public void CallMethodWithExpressionParameter ()
                {
@@ -292,7 +296,7 @@ namespace MonoTests.System.Linq.Expressions {
 
                        Assert.AreEqual (42, l ());
                }
-
+#endif
                static bool fout_called = false;
 
                public static int FooOut (out int x)
@@ -447,7 +451,6 @@ namespace MonoTests.System.Linq.Expressions {
 
 
                [Test]
-               [Category ("NotWorking")]
                public void CallQueryableSelect () // #536637
                {
                        var parameter = Expression.Parameter (typeof (string), "s");
@@ -458,7 +461,7 @@ namespace MonoTests.System.Linq.Expressions {
 
                        var call = Expression.Call (
                                typeof (Queryable),
-                               "select",
+                               "Select",
                                new [] { typeof (string), typeof (int) },
                                Expression.Constant (strings.AsQueryable ()),
                                lambda);
@@ -472,5 +475,24 @@ namespace MonoTests.System.Linq.Expressions {
                        Assert.AreEqual (typeof (string), method.GetGenericArguments () [0]);
                        Assert.AreEqual (typeof (int), method.GetGenericArguments () [1]);
                }
+
+               [Test]
+               public void CallNullableGetValueOrDefault () // #568989
+               {
+                       var value = Expression.Parameter (typeof (int?), "value");
+                       var default_parameter = Expression.Parameter (typeof (int), "default");
+
+                       var getter = Expression.Lambda<Func<int?, int, int>> (
+                               Expression.Call (
+                                       value,
+                                       "GetValueOrDefault",
+                                       Type.EmptyTypes,
+                                       default_parameter),
+                               value,
+                               default_parameter).Compile ();
+
+                       Assert.AreEqual (2, getter (null, 2));
+                       Assert.AreEqual (4, getter (4, 2));
+               }
        }
 }