Exemple #1
0
        public void Escape_Expression()
        {
            var expression = Expression.Constant("test[test");

            var result = SqlLikeExpression.Escape(expression, @"\");

            var expectedResult =
                new SqlFunctionExpression(typeof(string), "REPLACE",
                                          new SqlFunctionExpression(typeof(string), "REPLACE",
                                                                    new SqlFunctionExpression(typeof(string), "REPLACE",
                                                                                              new SqlFunctionExpression(typeof(string), "REPLACE", expression,
                                                                                                                        new SqlLiteralExpression(@"\"), new SqlLiteralExpression(@"\\")),
                                                                                              new SqlLiteralExpression("%"), new SqlLiteralExpression(@"\%")),
                                                                    new SqlLiteralExpression("_"), new SqlLiteralExpression(@"\_")),
                                          new SqlLiteralExpression("["), new SqlLiteralExpression(@"\["));

            SqlExpressionTreeComparer.CheckAreEqualTrees(expectedResult, result);
        }
Exemple #2
0
        public void Escape_Bracket()
        {
            var result = SqlLikeExpression.Escape("test[test", @"\");

            Assert.That(result, Is.EqualTo(@"test\[test"));
        }
Exemple #3
0
        public void Escape_Underline()
        {
            var result = SqlLikeExpression.Escape("test_test", @"\");

            Assert.That(result, Is.EqualTo(@"test\_test"));
        }
Exemple #4
0
        public void Escape_EscapeSequence()
        {
            var result = SqlLikeExpression.Escape(@"test\test", @"\");

            Assert.That(result, Is.EqualTo(@"test\\test"));
        }
Exemple #5
0
        public void Escape_Percent()
        {
            var result = SqlLikeExpression.Escape("test%test", @"\");

            Assert.That(result, Is.EqualTo(@"test\%test"));
        }