}
[Test]
+#if NET_4_0
+ [ExpectedException (typeof (ArgumentException))]
+#else
[ExpectedException (typeof (ArgumentNullException))]
+#endif
public void ArgInstanceNullForNonStaticMethod ()
{
Expression.Call (null, typeof (object).GetMethod ("ToString"));
{
return (int) (i as ConstantExpression).Value;
}
-
+#if !NET_4_0 // dlr bug 5875
[Test]
public void CallMethodWithExpressionParameter ()
{
Assert.AreEqual (42, l ());
}
-
+#endif
static bool fout_called = false;
public static int FooOut (out int x)
[Test]
- [Category ("NotWorking")]
public void CallQueryableSelect () // #536637
{
var parameter = Expression.Parameter (typeof (string), "s");
var call = Expression.Call (
typeof (Queryable),
- "select",
+ "Select",
new [] { typeof (string), typeof (int) },
Expression.Constant (strings.AsQueryable ()),
lambda);
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));
+ }
}
}