public Transform ( |
||
methodCallExpression | ||
Résultat |
public void Transform_TwoArguments () { var method = typeof (StringExtensions).GetMethod ( "SqlContainsFulltext", BindingFlags.Public | BindingFlags.Static, null, CallingConventions.Any, new[] { typeof (string), typeof (string), typeof (string) }, null); var objectExpression = Expression.Constant ("Test"); var argument1 = Expression.Constant ("es"); var language = Expression.Constant ("language"); var expression = Expression.Call (method, objectExpression, argument1, language); var transformer = new ContainsFreetextMethodCallTransformer(); var result = transformer.Transform (expression); var argumentExpression = Expression.Constant (string.Format ("{0}", argument1.Value)); var compositeExpression = new SqlCompositeCustomTextGeneratorExpression ( typeof (string), new SqlCustomTextExpression ("LANGUAGE ", typeof (string)), language); var expectedResult = new SqlFunctionExpression (typeof (bool), "FREETEXT", objectExpression, argumentExpression, compositeExpression); SqlExpressionTreeComparer.CheckAreEqualTrees (expectedResult, result); }
public void Transform_OneArgument () { var method = typeof (StringExtensions).GetMethod ( "SqlContainsFulltext", BindingFlags.Public | BindingFlags.Static, null, CallingConventions.Any, new[] { typeof (string), typeof (string) }, null); var objectExpression = Expression.Constant ("Test"); var argument1 = Expression.Constant ("es"); var expression = Expression.Call (method, objectExpression, argument1); var transformer = new ContainsFreetextMethodCallTransformer(); var result = transformer.Transform (expression); var rightExpression = Expression.Constant (string.Format ("{0}", argument1.Value)); var expectedResult = new SqlFunctionExpression (typeof (bool), "FREETEXT", objectExpression, rightExpression); SqlExpressionTreeComparer.CheckAreEqualTrees (expectedResult, result); }