public void GetParametersTest_OneKeyword() { ISqlExpression expression = SqlStringExpression.FromParameter(new SqlParameter("@p", true)); SqlOperator op = new SqlOperator("NOT", new SqlKeywordsOperatorResultSqlStringProvider("NOT"), new SqlKeywordsOperatorResultParametersProvider(1)); ReadOnlyCollection <IDataParameter> parameters = op.Compute(expression).Parameters; Assert.AreEqual <int>(1, parameters.Count); Assert.IsTrue(parameters.Contains(expression.Parameters[0])); }
public void GetParametersTest_MoreKeywords() { ISqlExpression expression0 = SqlStringExpression.FromParameter(new SqlParameter("@p0", true)); ISqlExpression expression1 = SqlStringExpression.FromParameter(new SqlParameter("@p1", true)); SqlOperator op = new SqlOperator("ADD", new SqlKeywordsOperatorResultSqlStringProvider("+"), new SqlKeywordsOperatorResultParametersProvider(1)); ReadOnlyCollection <IDataParameter> parameters = op.Compute(expression0, expression1).Parameters; Assert.AreEqual <int>(2, parameters.Count); Assert.IsTrue(parameters.Contains(expression0.Parameters[0])); Assert.IsTrue(parameters.Contains(expression1.Parameters[0])); }
public void GetParametersTest() { ISqlExpression expression0 = new SqlStringExpression("ID"); ISqlExpression expression1 = SqlStringExpression.FromParameter(new SqlParameter("@p1", 1)); ISqlExpression expression2 = SqlStringExpression.FromParameter(new SqlParameter("@p2", 2)); SqlOperator op = new SqlOperator("IN", new SqlInOperatorResultSqlStringProvider(), new SqlOperatorResultAllParametersProvider()); ReadOnlyCollection <IDataParameter> parameters = op.Compute(expression0, expression1, expression2).Parameters; Assert.AreEqual <int>(2, parameters.Count); Assert.IsTrue(parameters.Contains(expression1.Parameters[0])); Assert.IsTrue(parameters.Contains(expression2.Parameters[0])); }
public void GetSqlStringTest() { ISqlExpression expression0 = new SqlStringExpression("ID"); ISqlExpression expression1 = new SqlStringExpression("1"); SqlOperator op = new SqlOperator("Assign", new SqlAssignOperatorResultSqlStringProvider(), new SqlKeywordsOperatorResultParametersProvider(1)); Assert.AreEqual <string>(string.Format("{0} = ({1})", expression0.SqlString, expression1.SqlString), op.Compute(expression0, expression1).SqlString); }
public void GetSqlStringTest_MoreKeywords() { ISqlExpression expression0 = new SqlStringExpression("1"); ISqlExpression expression1 = new SqlStringExpression("2"); SqlOperator op = new SqlOperator("ADD", new SqlKeywordsOperatorResultSqlStringProvider("+"), new SqlKeywordsOperatorResultParametersProvider(1)); Assert.AreEqual <string>(string.Format("({0}) + ({1})", expression0.SqlString, expression1.SqlString), op.Compute(expression0, expression1).SqlString); }
public void GetSqlStringTest_OneKeyword() { ISqlExpression expression = new SqlStringExpression("1 > 2"); SqlOperator op = new SqlOperator("NOT", new SqlKeywordsOperatorResultSqlStringProvider("NOT"), new SqlKeywordsOperatorResultParametersProvider(1)); Assert.AreEqual <string>(string.Format("NOT ({0})", expression.SqlString), op.Compute(expression).SqlString); }
public void GetSqlStringTest_MoreOperands() { ISqlExpression expression0 = new SqlStringExpression("ID"); ISqlExpression expression1 = new SqlStringExpression("1"); ISqlExpression expression2 = new SqlStringExpression("2"); SqlOperator op = new SqlOperator("IN", new SqlInOperatorResultSqlStringProvider(), new SqlOperatorResultAllParametersProvider()); Assert.AreEqual <string>(string.Format("({0}) IN ({1}, {2})", expression0.SqlString, expression1.SqlString, expression2.SqlString), op.Compute(expression0, expression1, expression2).SqlString); }