Exemplo n.º 1
0
        public void BuildExpression_TrivialSelectTrivialWhere()
        {
            MySQLBuilder sqlBuilder = new MySQLBuilder();

            sqlBuilder.AddSelectClause("1");
            sqlBuilder.AddWhereClause("1 = 0", ExpressionType.Or);

            StringBuilder stringBuilder = new StringBuilder();

            sqlBuilder.BuildExpression(stringBuilder);

            Assert.AreEqual("SELECT DISTINCT 1 WHERE  1 = 0 ;", stringBuilder.ToString());
        }
Exemplo n.º 2
0
        public void Clone_SimpleTest()
        {
            SQLBuilder sqlBuilder = new MySQLBuilder();

            sqlBuilder.AddSelectClause("name");
            sqlBuilder.AddFromClause("employees");
            sqlBuilder.AddWhereClause("id=42", ExpressionType.And);

            SQLBuilder clonedBuilder = (SQLBuilder) sqlBuilder.Clone();

            sqlBuilder.AddCountClause(typeof(Employee));

            StringBuilder stringBuilder = new StringBuilder();
            sqlBuilder.BuildExpression(stringBuilder);

            Assert.AreEqual("SELECT COUNT(*) AS numrows FROM employees WHERE  id=42 ;", stringBuilder.ToString());

            stringBuilder = new StringBuilder();

            clonedBuilder.BuildExpression(stringBuilder);

            Assert.AreEqual("SELECT DISTINCT name FROM employees WHERE  id=42 ;", stringBuilder.ToString());
        }
Exemplo n.º 3
0
        public void BuildExpression_SelectFromWhere()
        {
            MySQLBuilder sqlBuilder = new MySQLBuilder();

            sqlBuilder.AddSelectClause("name");
            sqlBuilder.AddFromClause("employees");
            sqlBuilder.AddWhereClause("id=42", ExpressionType.And);

            StringBuilder stringBuilder = new StringBuilder();

            sqlBuilder.BuildExpression(stringBuilder);

            Assert.AreEqual("SELECT DISTINCT name FROM employees WHERE  id=42 ;", stringBuilder.ToString());
        }