public void BasicTest_2_Condition()
        {
            SelectStmtInfo stmtInfo = new SelectStmtInfo();

            stmtInfo.Columns.Add(new Column() { Expression = new ColumnExpression(ExpressionType.ColumnName) { ColumnName = "userId" } });
            stmtInfo.Columns.Add(new Column() { Expression = new ColumnExpression(ExpressionType.ColumnName) { ColumnName = "userName" } });

            stmtInfo.TableDescriptor = new TableDescriptor() { TableName = "me", TableReadType = TableReadType.NONE };

            stmtInfo.WhereCondition = new WhereCondition(WhereConditionNodeType.Statement);

            stmtInfo.WhereCondition.Statement_Operator = "AND";

            stmtInfo.WhereCondition.Statement_LeftNode = new WhereCondition(WhereConditionNodeType.Condition);
            stmtInfo.WhereCondition.Statement_LeftNode.Condition_LeftExpression = "userId";
            stmtInfo.WhereCondition.Statement_LeftNode.Condition_Operator = ">";
            stmtInfo.WhereCondition.Statement_LeftNode.Condition_RightExpression = "5";

            stmtInfo.WhereCondition.Statement_RightNode = new WhereCondition(WhereConditionNodeType.Condition);
            stmtInfo.WhereCondition.Statement_RightNode.Condition_LeftExpression = "sex";
            stmtInfo.WhereCondition.Statement_RightNode.Condition_Operator = "=";
            stmtInfo.WhereCondition.Statement_RightNode.Condition_RightExpression = "1";

            stmtInfo.OrderBy.Add(new OrderByCondition() { Expression = "userId", Direction = OrderByDirection.ASC });

            IGenerator g = new DefaultSqlGenerator();

            var sql = g.Generate(stmtInfo);

            Assert.AreEqual("SELECT userId, userName FROM me WHERE (userId>5) AND (sex=1) ORDER BY userId ASC", sql);
        }
        public void BasicTest_Alias_READPAST()
        {
            SelectStmtInfo stmtInfo = new SelectStmtInfo();

            stmtInfo.Columns.Add(new Column() { Expression = new ColumnExpression(ExpressionType.ColumnName) { ColumnName = "userId" }, HasAlias = true, Alias = "UID" });
            stmtInfo.Columns.Add(new Column() { Expression = new ColumnExpression(ExpressionType.ColumnName) { ColumnName = "userName" } });

            stmtInfo.TableDescriptor = new TableDescriptor() { TableName = "me", TableReadType = TableReadType.READPAST };

            IGenerator g = new DefaultSqlGenerator();

            var sql = g.Generate(stmtInfo);

            Assert.AreEqual("SELECT userId AS UID, userName FROM me(READPAST)", sql);
        }
        public void BasicTest_NO_WHERE_NO_ORDERBY()
        {
            SelectStmtInfo stmtInfo = new SelectStmtInfo();

            stmtInfo.Columns.Add(new Column() { Expression=new ColumnExpression(ExpressionType.ColumnName){ ColumnName="userId"}});
            stmtInfo.Columns.Add(new Column() { Expression = new ColumnExpression(ExpressionType.ColumnName) { ColumnName = "userName" } });

            stmtInfo.TableDescriptor = new TableDescriptor() { TableName = "me", TableReadType= TableReadType.NONE };

            IGenerator g = new DefaultSqlGenerator();

            var sql=g.Generate(stmtInfo);

            Assert.AreEqual("SELECT userId, userName FROM me", sql);
        }
        public void BasicTest_ORDERBY2()
        {
            SelectStmtInfo stmtInfo = new SelectStmtInfo();

            stmtInfo.Columns.Add(new Column() { Expression = new ColumnExpression(ExpressionType.ColumnName) { ColumnName = "userId" } });
            stmtInfo.Columns.Add(new Column() { Expression = new ColumnExpression(ExpressionType.ColumnName) { ColumnName = "userName" } });

            stmtInfo.TableDescriptor = new TableDescriptor() { TableName = "me", TableReadType = TableReadType.NONE };

            stmtInfo.OrderBy.Add(new OrderByCondition() { Expression = "userId", Direction = OrderByDirection.ASC });
            stmtInfo.OrderBy.Add(new OrderByCondition() { Expression = "userName", Direction = OrderByDirection.DESC });

            IGenerator g = new DefaultSqlGenerator();

            var sql = g.Generate(stmtInfo);

            Assert.AreEqual("SELECT userId, userName FROM me ORDER BY userId ASC, userName DESC", sql);
        }