ContainsMethodCallTransformer implements IMethodCallTransformer for the string.Contains method.
Inheritance: IMethodCallTransformer
    public void Transform_ArgumentIsNotNull ()
    {
      var method = typeof (string).GetMethod ("Contains", new[] { typeof (string) });
      var objectExpression = Expression.Constant ("Test");
      var argument1 = Expression.Constant ("test");
      var expression = Expression.Call (objectExpression, method, argument1);
      var transformer = new ContainsMethodCallTransformer();

      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 ("Contains", 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 ContainsMethodCallTransformer();

      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) }));
      rightExpression = Expression.Add (
          rightExpression, new SqlLiteralExpression ("%"), typeof (string).GetMethod ("Concat", new[] { typeof (string), typeof (string) }));
      var expectedResult = new SqlLikeExpression (objectExpression, rightExpression, new SqlLiteralExpression (@"\"));

      SqlExpressionTreeComparer.CheckAreEqualTrees (expectedResult, result);
    }
    public void Transform_ArgumentIsNull ()
    {
      var method = typeof (string).GetMethod ("Contains", 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 ContainsMethodCallTransformer();

      var result = transformer.Transform (expression);

      SqlExpressionTreeComparer.CheckAreEqualTrees (Expression.Constant (false), result);
    }