Пример #1
0
        public void QuotedAndParenthesisStringTokenizerTests_WithFunctionCallContainingComma()
        {
            var tokenizier =
                new Dialect.Dialect.QuotedAndParenthesisStringTokenizer(
                    new SqlString("SELECT fish.id, cast('astring, with,comma' as string) as bar, f FROM fish"));
            var expected = new string[]
            {
                "SELECT",
                "fish.id",
                ",",
                "cast('astring, with,comma' as string)",
                "as",
                "bar",
                ",",
                "f",
                "FROM",
                "fish"
            };
            var current = 0;
            var tokens  = tokenizier.GetTokens();

            foreach (var token in tokens)
            {
                Assert.AreEqual(expected[current], token.ToString());
                current += 1;
            }
            Assert.AreEqual(current, expected.Length);
        }
Пример #2
0
        public void QuotedStringTokenizerTests()
        {
            var tokenizier =
                new Dialect.Dialect.QuotedAndParenthesisStringTokenizer(
                    new SqlString("SELECT fish.\"id column\", fish.'fish name' as 'bar\\' column', f FROM fish"));
            var expected = new string[]
            {
                "SELECT",
                "fish.\"id column\"",
                ",",
                "fish.'fish name'",
                "as",
                "'bar\\' column'",
                ",",
                "f",
                "FROM",
                "fish"
            };
            var current = 0;
            var tokens  = tokenizier.GetTokens();

            foreach (var token in tokens)
            {
                Assert.AreEqual(expected[current], token.ToString());
                current += 1;
            }
            Assert.That(expected, Has.Length.EqualTo(current));
        }
Пример #3
0
        public void QuotedAndParenthesisStringTokenizerTests_WithComma_InQuotes()
        {
            var tokenizier =
                new Dialect.Dialect.QuotedAndParenthesisStringTokenizer(
                    new SqlString("select concat(a.Description,', ', a.Description) from Animal a"));
            var expected = new string[]
            {
                "select",
                "concat(a.Description,', ', a.Description)",
                "from",
                "Animal",
                "a"
            };
            var current = 0;

            foreach (SqlString token in tokenizier)
            {
                Assert.AreEqual(expected[current], token.ToString());
                current += 1;
            }
            Assert.AreEqual(current, expected.Length);
        }