Ejemplo n.º 1
0
        public void AnsiSubstring()
        {
            //ANSI-SQL92 definition
            // <character substring function> ::=
            // SUBSTRING <left paren> <character value expression> FROM < start position>
            // [ FOR <string length> ] <right paren>
            IList args = new ArrayList();

            AnsiSubstringFunction asf = new AnsiSubstringFunction();

            args.Add("var1");
            args.Add("3");
            Assert.AreEqual("substring(var1 from 3)", asf.Render(args, factoryImpl).ToString());

            args.Add("4");
            Assert.AreEqual("substring(var1 from 3 for 4)", asf.Render(args, factoryImpl).ToString());

            args.Clear();
            Assert.Throws <QueryException>(() => asf.Render(args, factoryImpl), "Expected 'Not enough parameters' exception");
            args.Clear();
            args.Add("1");
            args.Add("2");
            args.Add("3");
            args.Add("4");
            Assert.Throws <QueryException>(() => asf.Render(args, factoryImpl), "Expected 'Not enough parameters' exception");
        }
Ejemplo n.º 2
0
        public void AnsiSubstring()
        {
            //ANSI-SQL92 definition
            // <character substring function> ::=
            // SUBSTRING <left paren> <character value expression> FROM < start position>
            // [ FOR <string length> ] <right paren>
            IList args = new ArrayList();

            AnsiSubstringFunction asf = new AnsiSubstringFunction();

            args.Add("var1");
            args.Add("3");
            Assert.AreEqual("substring(var1 from 3)", asf.Render(args, factoryImpl).ToString());

            args.Add("4");
            Assert.AreEqual("substring(var1 from 3 for 4)", asf.Render(args, factoryImpl).ToString());

            args.Clear();
            try
            {
                SqlString t = asf.Render(args, factoryImpl);
                Assert.Fail("Not threw 'Not enough parameters' exception:" + t);
            }
            catch (QueryException)
            {
                //correct
            }
            args.Clear();
            args.Add("1");
            args.Add("2");
            args.Add("3");
            args.Add("4");
            try
            {
                SqlString t = asf.Render(args, factoryImpl);
                Assert.Fail("Not threw 'Not enough parameters' exception:" + t);
            }
            catch (QueryException)
            {
                //correct
            }
        }