예제 #1
0
        public void ClassicSum()
        {
            //ANSI-SQL92 definition
            //<general set function> ::=
            //<set function type> <leftparen> [ <setquantifier> ] <value expression> <right paren>
            //<set function type> : := AVG | MAX | MIN | SUM | COUNT
            //<setquantifier> ::= DISTINCT | ALL
            IList args = new ArrayList();

            ClassicSumFunction csf = new ClassicSumFunction();

            args.Add("va1");
            Assert.AreEqual("sum(va1)", csf.Render(args, factoryImpl).ToString());

            args.Clear();
            args.Add("distinct");
            args.Add("va2");
            Assert.AreEqual("sum(distinct va2)", csf.Render(args, factoryImpl).ToString());

            args.Clear();
            args.Add("va1");
            args.Add("va2");
            try
            {
                SqlString t = csf.Render(args, factoryImpl);
                Assert.Fail("No exception 2 argument without <setquantifier>:" + t);
            }
            catch (QueryException)
            {
                //correct
            }
        }
예제 #2
0
        public void ClassicSum()
        {
            //ANSI-SQL92 definition
            //<general set function> ::=
            //<set function type> <left paren> [ <setquantifier> ] <value expression> <right paren>
            //<set function type> : := AVG | MAX | MIN | SUM | COUNT
            //<setquantifier> ::= DISTINCT | ALL
            IList args = new ArrayList();

            ClassicSumFunction csf = new ClassicSumFunction();

            args.Add("va1");
            Assert.AreEqual("sum(va1)", csf.Render(args, factoryImpl).ToString());

            args.Clear();
            args.Add("distinct");
            args.Add("va2");
            Assert.AreEqual("sum(distinct va2)", csf.Render(args, factoryImpl).ToString());

            args.Clear();
            args.Add("va1");
            args.Add("va2");
            Assert.Throws <QueryException>(() => csf.Render(args, factoryImpl));
        }