コード例 #1
0
        public void TestOrInBracketsWithAndOutsideBrackets()
        {
            IExpression  exp = Expression.CreateExpression("param1 = 'test' AND (param2 = 3 or param2 = 4)");
            SqlStatement st  = CreateSqlStatement();

            exp.SqlExpressionString(st, "", "");
            Assert.AreEqual("(param1 = " + GetParamName(0) + " AND (param2 = " + GetParamName(1) + " OR param2 = " + GetParamName(2) + "))", st.Statement.ToString());
        }
コード例 #2
0
        public void TestExpressionParsingSqlSingleParameter()
        {
            IExpression  exp = Expression.CreateExpression("Field1 = 'test'");
            SqlStatement st  = CreateSqlStatement();

            exp.SqlExpressionString(st, "", "");
            Assert.AreEqual("Field1 = " + GetParamName(0) + "", st.Statement.ToString());
            Assert.AreEqual("test", st.Parameters[0].Value);
        }
コード例 #3
0
        public void TestExpressionParsingSql()
        {
            IExpression  exp = Expression.CreateExpression("Field1 = 'test' and Field2 = 'test2' or Field2 = 'test2'");
            SqlStatement st  = CreateSqlStatement();

            exp.SqlExpressionString(st, "", "");
            Assert.AreEqual("((Field1 = " + GetParamName(0) + " AND Field2 = " + GetParamName(1) + ") OR Field2 = " + GetParamName(2) + ")", st.Statement.ToString());
            Assert.AreEqual("test", st.Parameters[0].Value);
            Assert.AreEqual("test2", st.Parameters[1].Value);
            Assert.AreEqual("test2", st.Parameters[2].Value);
        }
コード例 #4
0
        public void TestParameterSqlInfo()
        {
            IParameterSqlInfo paramSql1 =
                new MockParameterSqlInfo("testfieldname", "paramName", Habanero.Base.ParameterType.String, "tbl");
            IExpression exp = Expression.CreateExpression("paramName = 'test'");

            exp.SetParameterSqlInfo(paramSql1);
            SqlStatement st = CreateSqlStatement();

            exp.SqlExpressionString(st, "", "");
            Assert.AreEqual("tbl.testfieldname = " + GetParamName(0) + "", st.Statement.ToString());
            Assert.AreEqual("test", st.Parameters[0].Value);
        }
コード例 #5
0
        public void TestParameterSqlInfoWithMoreThanOne()
        {
            IParameterSqlInfo paramSql1 =
                new MockParameterSqlInfo("testfieldname", "paramName", ParameterType.String, "tbl");
            IParameterSqlInfo paramSql2 =
                new MockParameterSqlInfo("testfieldname2", "paramName2", ParameterType.Date, "tbl2");
            IExpression exp = Expression.CreateExpression("paramName = 'test' and paramName2 = '10 Feb 2003'");

            exp.SetParameterSqlInfo(paramSql2);
            exp.SetParameterSqlInfo(paramSql1);
            SqlStatement st = CreateSqlStatement();

            exp.SqlExpressionString(st, "", "");
            Assert.AreEqual("(tbl.testfieldname = " + GetParamName(0) + " AND tbl2.testfieldname2 = " + GetParamName(1) + ")", st.Statement.ToString());
            Assert.AreEqual("test", st.Parameters[0].Value);
            Assert.AreEqual(new DateTime(2003, 02, 10), st.Parameters[1].Value);
        }