示例#1
0
        public void CastFunc()
        {
            IList args = new ArrayList();

            CastFunction cf = new CastFunction();

            Assert.Throws <QueryException>(() => cf.Render(args, factoryImpl));

            args.Add("'123'");
            args.Add("long");
            string expected =
                string.Format("cast({0} as {1})", args[0], factoryImpl.Dialect.GetCastTypeName(SqlTypeFactory.Int64));

            Assert.AreEqual(expected, cf.Render(args, factoryImpl).ToString());

            args.Clear();
            args.Add("'123'");
            args.Add("NO_TYPE");
            Assert.Throws <QueryException>(() => cf.Render(args, factoryImpl), "Invalid type accepted");
        }
示例#2
0
        public void CastFunc()
        {
            IList args = new ArrayList();

            CastFunction cf = new CastFunction();

            try
            {
                SqlString t = cf.Render(args, factoryImpl);
                Assert.Fail("No exception if no argument");
            }
            catch (QueryException)
            {
                //correct
            }

            args.Add("'123'");
            args.Add("long");
            string expected =
                string.Format("cast({0} as {1})", args[0], factoryImpl.Dialect.GetCastTypeName(SqlTypeFactory.Int64));

            Assert.AreEqual(expected, cf.Render(args, factoryImpl).ToString());

            args.Clear();
            args.Add("'123'");
            args.Add("NO_TYPE");
            try
            {
                SqlString t = cf.Render(args, factoryImpl);
                Assert.Fail("Ivalid type accepted");
            }
            catch (QueryException)
            {
                //correct
            }
        }