public Transform ( |
||
methodCallExpression | ||
리턴 |
public void Transform () { var method = typeof (string).GetMethod ("Insert", new[] { typeof(int), typeof(string) }); var objectExpression = Expression.Constant ("Test"); var argument1 = Expression.Constant(3); var argument2 = Expression.Constant("what"); var expression = Expression.Call (objectExpression, method, argument1, argument2); var transformer = new InsertMethodCallTransformer (); var result = transformer.Transform (expression); var expectedTestExpression = Expression.Equal (new SqlLengthExpression (objectExpression), Expression.Add (argument1, new SqlLiteralExpression (1))); var concatMethod = typeof (string).GetMethod ("Concat", new[] { typeof (string), typeof (string) }); var expectedThenExpression = Expression.Add (objectExpression, argument2, concatMethod); var expectedElseExpression = new SqlFunctionExpression (typeof (string), "STUFF", objectExpression, Expression.Add (argument1, new SqlLiteralExpression (1)), new SqlLiteralExpression(0), argument2); var expectedResult = Expression.Condition (expectedTestExpression, expectedThenExpression, expectedElseExpression); SqlExpressionTreeComparer.CheckAreEqualTrees (expectedResult, result); }