Ejemplo n.º 1
0
        public void QuotedStringTokenizerTests()
        {
            MsSql2005Dialect.QuotedAndParenthesisStringTokenizer tokenizier =
                new MsSql2005Dialect.QuotedAndParenthesisStringTokenizer(
                    new SqlString("SELECT fish.\"id column\", fish.'fish name' as 'bar\\' column', f FROM fish"));
            string[] expected = new string[]
            {
                "SELECT",
                "fish.\"id column\"",
                ",",
                "fish.'fish name'",
                "as",
                "'bar\\' column'",
                ",",
                "f",
                "FROM",
                "fish"
            };
            int current = 0;
            IList <SqlString> tokens = tokenizier.GetTokens();

            foreach (SqlString token in tokens)
            {
                Assert.AreEqual(expected[current], token.ToString());
                current += 1;
            }
            Assert.AreEqual(current, expected.Length);
        }
Ejemplo n.º 2
0
        public void QuotedAndParenthesisStringTokenizerTests_WithFunctionCallContainingComma()
        {
            MsSql2005Dialect.QuotedAndParenthesisStringTokenizer tokenizier =
                new MsSql2005Dialect.QuotedAndParenthesisStringTokenizer(
                    new SqlString("SELECT fish.id, cast('astring, with,comma' as string) as bar, f FROM fish"));
            string[] expected = new string[]
            {
                "SELECT",
                "fish.id",
                ",",
                "cast('astring, with,comma' as string)",
                "as",
                "bar",
                ",",
                "f",
                "FROM",
                "fish"
            };
            int current = 0;
            IList <SqlString> tokens = tokenizier.GetTokens();

            foreach (SqlString token in tokens)
            {
                Assert.AreEqual(expected[current], token.ToString());
                current += 1;
            }
            Assert.AreEqual(current, expected.Length);
        }
Ejemplo n.º 3
0
        public void QuotedAndParenthesisStringTokenizerTests_WithComma_InQuotes()
        {
            MsSql2005Dialect.QuotedAndParenthesisStringTokenizer tokenizier =
                new MsSql2005Dialect.QuotedAndParenthesisStringTokenizer(
                    new SqlString("select concat(a.Description,', ', a.Description) from Animal a"));
            string[] expected = new string[]
            {
                "select",
                "concat(a.Description,', ', a.Description)",
                "from",
                "Animal",
                "a"
            };
            int current = 0;

            foreach (SqlString token in tokenizier)
            {
                Assert.AreEqual(expected[current], token.ToString());
                current += 1;
            }
            Assert.AreEqual(current, expected.Length);
        }
		public void QuotedStringTokenizerTests()
		{
			MsSql2005Dialect.QuotedAndParenthesisStringTokenizer tokenizier =
				new MsSql2005Dialect.QuotedAndParenthesisStringTokenizer(
					new SqlString("SELECT fish.\"id column\", fish.'fish name' as 'bar\\' column', f FROM fish"));
			string[] expected = new string[]
				{
					"SELECT",
					"fish.\"id column\"",
					",",
					"fish.'fish name'",
					"as",
					"'bar\\' column'",
					",",
					"f",
					"FROM",
					"fish"
				};
			int current = 0;
			IList<SqlString> tokens = tokenizier.GetTokens();
			foreach (SqlString token in tokens)
			{
				Assert.AreEqual(expected[current], token.ToString());
				current += 1;
			}
			Assert.AreEqual(current, expected.Length);
		}
		public void QuotedAndParenthesisStringTokenizerTests_WithFunctionCallContainingComma()
		{
			MsSql2005Dialect.QuotedAndParenthesisStringTokenizer tokenizier =
				new MsSql2005Dialect.QuotedAndParenthesisStringTokenizer(
					new SqlString("SELECT fish.id, cast('astring, with,comma' as string) as bar, f FROM fish"));
			string[] expected = new string[]
				{
					"SELECT",
					"fish.id",
					",",
					"cast('astring, with,comma' as string)",
					"as",
					"bar",
					",",
					"f",
					"FROM",
					"fish"
				};
			int current = 0;
			IList<SqlString> tokens = tokenizier.GetTokens();
			foreach (SqlString token in tokens)
			{
				Assert.AreEqual(expected[current], token.ToString());
				current += 1;
			}
			Assert.AreEqual(current, expected.Length);
		}
		public void QuotedAndParenthesisStringTokenizerTests_WithComma_InQuotes()
		{
			MsSql2005Dialect.QuotedAndParenthesisStringTokenizer tokenizier =
				new MsSql2005Dialect.QuotedAndParenthesisStringTokenizer(
					new SqlString("select concat(a.Description,', ', a.Description) from Animal a"));
			string[] expected = new string[]
				{
					"select",
					"concat(a.Description,', ', a.Description)",
					"from",
					"Animal",
					"a"
				};
			int current = 0;
			foreach (SqlString token in tokenizier)
			{
				Assert.AreEqual(expected[current], token.ToString());
				current += 1;
			}
			Assert.AreEqual(current, expected.Length);
		}