EndsWithMethodCallTransformer implements IMethodCallTransformer for the string.EndsWith(string) method.
상속: IMethodCallTransformer
    public void Transform_ArgumentIsNull ()
    {
      var method = typeof (string).GetMethod ("EndsWith", new[] { typeof (string) });
      var objectExpression = Expression.Constant ("Test");
      var argument1 = Expression.Constant (null, typeof(string));
      var expression = Expression.Call (objectExpression, method, argument1);
      var transformer = new EndsWithMethodCallTransformer ();
      
      var result = transformer.Transform (expression);

      SqlExpressionTreeComparer.CheckAreEqualTrees (Expression.Constant(false), result);
    }
    public void Transform_ArgumentNotNull ()
    {
      var method = typeof (string).GetMethod ("EndsWith", new[] { typeof (string) });
      var objectExpression = Expression.Constant ("Test");
      var argument1 = Expression.Constant ("test");
      var expression = Expression.Call (objectExpression, method, argument1);
      var transformer = new EndsWithMethodCallTransformer();
      var result = transformer.Transform (expression);

      var rightExpression = Expression.Constant (string.Format ("%{0}", argument1.Value));

      var expectedResult = new SqlLikeExpression (objectExpression, rightExpression, new SqlLiteralExpression (@"\"));
      
      SqlExpressionTreeComparer.CheckAreEqualTrees (expectedResult, result);
    }
    public void Transform_ArgumentIsNotNullAndIsNoConstantValue_ ()
    {
      var method = typeof (string).GetMethod ("StartsWith", new[] { typeof (string) });
      var objectExpression = Expression.Constant ("Test");
      var argument1 = Expression.MakeMemberAccess (Expression.Constant (new Cook ()), typeof (Cook).GetProperty ("Name"));
      var expression = Expression.Call (objectExpression, method, argument1);
      var transformer = new EndsWithMethodCallTransformer ();

      var result = transformer.Transform (expression);

      Expression rightExpression = new SqlFunctionExpression (
          typeof (string),
          "REPLACE",
          new SqlFunctionExpression (
              typeof (string),
              "REPLACE",
                 new SqlFunctionExpression (
                    typeof (string),
                    "REPLACE",
                      new SqlFunctionExpression (
                          typeof (string),
                          "REPLACE",
                          argument1,
                          new SqlLiteralExpression (@"\"),
                          new SqlLiteralExpression (@"\\")),
                      new SqlLiteralExpression (@"%"),
                      new SqlLiteralExpression (@"\%")),
                  new SqlLiteralExpression (@"_"),
                  new SqlLiteralExpression (@"\_")),
              new SqlLiteralExpression (@"["),
              new SqlLiteralExpression (@"\["));
      rightExpression = Expression.Add (
          new SqlLiteralExpression ("%"), rightExpression, typeof (string).GetMethod ("Concat", new[] { typeof (string), typeof (string) }));
      var expectedResult = new SqlLikeExpression (objectExpression, rightExpression, new SqlLiteralExpression (@"\"));

      SqlExpressionTreeComparer.CheckAreEqualTrees (expectedResult, result);
    }