public static void SingleValueKeyEqual(object value1, object value2, bool expected) { var key1 = new IndexKey(SqlObject.New(SqlValueUtil.FromObject(value1))); var key2 = new IndexKey(SqlObject.New(SqlValueUtil.FromObject(value2))); Assert.Equal(expected, key1.Equals(key2)); }
public static void CompareSingleValue(object value1, object value2, int expetced) { var key1 = new IndexKey(SqlObject.New(SqlValueUtil.FromObject(value1))); var key2 = new IndexKey(SqlObject.New(SqlValueUtil.FromObject(value2))); Assert.Equal(expetced, key1.CompareTo(key2)); }
private static SqlBinaryExpression BinaryExpression(Func <SqlExpression, SqlExpression, SqlBinaryExpression> factory, object value1, object value2) { var left = SqlExpression.Constant(SqlObject.New(SqlValueUtil.FromObject(value1))); var right = SqlExpression.Constant(SqlObject.New(SqlValueUtil.FromObject(value2))); return(factory(left, right)); }
public static void CreateConstant(object value) { var obj = SqlObject.New(SqlValueUtil.FromObject(value)); var exp = SqlExpression.Constant(obj); Assert.NotNull(exp.Value); Assert.Equal(obj, exp.Value); }
public void CreateInvalidQuantify(SqlExpressionType expressionType, SqlExpressionType opType) { var left = SqlExpression.Constant(SqlObject.New(SqlValueUtil.FromObject(212))); var right = SqlExpression.Constant(SqlObject.New(SqlValueUtil.FromObject(array))); var binary = SqlExpression.Binary(opType, left, right); Assert.Throws <ArgumentException>(() => SqlExpression.Quantify(expressionType, binary)); }
public void GetSqlTypeOfVarAssign(string name, object value, SqlTypeCode typeCode, int p) { var exp = SqlExpression.VariableAssign(name, SqlExpression.Constant(SqlObject.New(SqlValueUtil.FromObject(value)))); var varType = exp.GetSqlType(context); var type = PrimitiveTypes.Type(typeCode, new { precision = p, maxSize = p, size = p }); Assert.Equal(type, varType); }
public async Task SimpleSelect(string column, SqlExpressionType op, object value, long expectedRowCount) { var columnName = new ObjectName(left.TableInfo.TableName, column); var expression = SqlExpression.Constant(SqlObject.New(SqlValueUtil.FromObject(value))); var result = await left.SimpleSelectAsync(null, columnName, op, expression); Assert.NotNull(result); Assert.Equal(expectedRowCount, result.RowCount); }
public static void CreateUnary(SqlExpressionType expressionType, object value) { var obj = SqlObject.New(SqlValueUtil.FromObject(value)); var operand = SqlExpression.Constant(obj); var exp = SqlExpression.Unary(expressionType, operand); Assert.NotNull(exp.Operand); Assert.IsType <SqlConstantExpression>(exp.Operand); }
public void GetVarAssingString(string name, object value, string expected) { var obj = SqlObject.New(SqlValueUtil.FromObject(value)); var exp = SqlExpression.Constant(obj); var varRef = SqlExpression.VariableAssign(name, exp); var sql = varRef.ToString(); Assert.Equal(expected, sql); }
public static void SerializeStringMatch(SqlExpressionType expressionType, string value, string pattern) { var exp = SqlExpression.StringMatch(expressionType, SqlExpression.Constant(SqlObject.New(SqlValueUtil.FromObject(value))), SqlExpression.Constant(SqlObject.New(SqlValueUtil.FromObject(pattern))), null); var result = BinarySerializeUtil.Serialize(exp); Assert.Equal(exp.ExpressionType, result.ExpressionType); }
public static void SerializeUnary(SqlExpressionType expressionType, object value) { var obj = SqlObject.New(SqlValueUtil.FromObject(value)); var operand = SqlExpression.Constant(obj); var exp = SqlExpression.Unary(expressionType, operand); var result = BinarySerializeUtil.Serialize(exp); Assert.Equal(exp.ExpressionType, result.ExpressionType); }
public static void GetCastType(object value, SqlTypeCode destTypeCode, int p, int s) { var targetType = PrimitiveTypes.Type(destTypeCode, new { precision = p, scale = s, maxSize = p, size = p }); var obj = SqlObject.New(SqlValueUtil.FromObject(value)); var exp = SqlExpression.Constant(obj); var cast = SqlExpression.Cast(exp, targetType); Assert.Equal(targetType, cast.TargetType); }
public static void GetUnaryString(SqlExpressionType expressionType, object value, string expected) { var obj = SqlObject.New(SqlValueUtil.FromObject(value)); var operand = SqlExpression.Constant(obj); var exp = SqlExpression.Unary(expressionType, operand); var s = exp.ToString(); Assert.Equal(expected, s); }
public static void GetUnaryType(SqlExpressionType expressionType, object value) { var obj = SqlObject.New(SqlValueUtil.FromObject(value)); var operand = SqlExpression.Constant(obj); var exp = SqlExpression.Unary(expressionType, operand); var sqlType = exp.Type; Assert.Equal(obj.Type, sqlType); }
public void CreateVarAssign(string name, object value) { var obj = SqlObject.New(SqlValueUtil.FromObject(value)); var exp = SqlExpression.Constant(obj); var varRef = SqlExpression.VariableAssign(name, exp); Assert.NotNull(varRef.Value); Assert.Equal(exp, varRef.Value); Assert.Equal(name, varRef.VariableName); }
private static SqlExpression FormDefaultValue(object value) { if (value == null) { return(null); } var obj = SqlObject.New(SqlValueUtil.FromObject(value)); return(SqlExpression.Constant(obj)); }
public void CreateQuantify(SqlExpressionType expressionType, SqlExpressionType opType) { var left = SqlExpression.Constant(SqlObject.New(SqlValueUtil.FromObject(212))); var right = SqlExpression.Constant(SqlObject.New(SqlValueUtil.FromObject(array))); var binary = SqlExpression.Binary(opType, left, right); var exp = SqlExpression.Quantify(expressionType, binary); Assert.Equal(expressionType, exp.ExpressionType); Assert.Equal(opType, exp.Expression.ExpressionType); }
public static void CreateStringMatch(SqlExpressionType expressionType, string value, string pattern) { var exp = SqlExpression.StringMatch(expressionType, SqlExpression.Constant(SqlObject.New(SqlValueUtil.FromObject(value))), SqlExpression.Constant(SqlObject.New(SqlValueUtil.FromObject(pattern))), null); Assert.NotNull(exp); Assert.Equal(expressionType, exp.ExpressionType); Assert.NotNull(exp.Left); Assert.NotNull(exp.Pattern); }
public static void GetStringMatchString(SqlExpressionType expressionType, string value, string pattern, string expected) { var exp = SqlExpression.StringMatch(expressionType, SqlExpression.Constant(SqlObject.New(SqlValueUtil.FromObject(value))), SqlExpression.Constant(SqlObject.New(SqlValueUtil.FromObject(pattern))), null); var sql = exp.ToString(); Assert.Equal(expected, sql); }
public static void MultiValueKeyEqualToNull(object value1, object value2) { var key1 = new IndexKey(new[] { SqlObject.New(SqlValueUtil.FromObject(value1)), SqlObject.New(SqlValueUtil.FromObject(value2)) }); var key2 = key1.NullKey; Assert.NotEqual(key1, key2); Assert.True(key2.IsNull); }
public static void SerializeCast(object value, SqlTypeCode destTypeCode, int p, int s) { var targetType = PrimitiveTypes.Type(destTypeCode, new { precision = p, scale = s, maxSize = p, size = p }); var obj = SqlObject.New(SqlValueUtil.FromObject(value)); var exp = SqlExpression.Constant(obj); var cast = SqlExpression.Cast(exp, targetType); var result = BinarySerializeUtil.Serialize(cast); Assert.IsType <SqlConstantExpression>(result.Value); }
public static void GetBinaryString(SqlExpressionType expressionType, object value1, object value2, string expected) { var obj1 = SqlObject.New(SqlValueUtil.FromObject(value1)); var obj2 = SqlObject.New(SqlValueUtil.FromObject(value2)); var exp = SqlExpression.Binary(expressionType, SqlExpression.Constant(obj1), SqlExpression.Constant(obj2)); var s = exp.ToString(); Assert.Equal(expected, s); }
public async Task NonCorrelatedSelect(string column, SqlExpressionType op, SqlExpressionType subOp, object value1, object value2, long expected) { var columnName = new ObjectName(left.TableInfo.TableName, column); var exp1 = SqlExpression.Constant(SqlObject.New(SqlValueUtil.FromObject(value1))); var exp2 = SqlExpression.Constant(SqlObject.New(SqlValueUtil.FromObject(value2))); var array = SqlExpression.Constant(SqlObject.Array(new SqlArray(new[] { exp1, exp2 }))); var result = await left.SelectNonCorrelatedAsync(null, columnName, op, subOp, array); Assert.NotNull(result); Assert.Equal(expected, result.RowCount); }
public static void GetReferenceAssignString(string name, object value, string expected) { var objName = ObjectName.Parse(name); var obj = SqlObject.New(SqlValueUtil.FromObject(value)); var exp = SqlExpression.Constant(obj); var refAssign = SqlExpression.ReferenceAssign(objName, exp); var sql = refAssign.ToString(); Assert.Equal(expected, sql); }
public static void SerializeBinary(SqlExpressionType type, object value1, object value2) { var binary = SqlExpression.Binary(type, SqlExpression.Constant(SqlObject.New(SqlValueUtil.FromObject(value1))), SqlExpression.Constant(SqlObject.New(SqlValueUtil.FromObject(value2)))); var result = BinarySerializeUtil.Serialize(binary); Assert.Equal(binary.ExpressionType, result.ExpressionType); Assert.Equal(binary.Left.ExpressionType, result.Left.ExpressionType); Assert.Equal(binary.Right.ExpressionType, result.Right.ExpressionType); }
public static void CreateBinary(SqlExpressionType expressionType, object value1, object value2) { var obj1 = SqlObject.New(SqlValueUtil.FromObject(value1)); var obj2 = SqlObject.New(SqlValueUtil.FromObject(value2)); var exp = SqlExpression.Binary(expressionType, SqlExpression.Constant(obj1), SqlExpression.Constant(obj2)); Assert.NotNull(exp); Assert.NotNull(exp.Left); Assert.NotNull(exp.Right); }
public static void GetBinarySqlType(SqlExpressionType expressionType, object value1, object value2) { var obj1 = SqlObject.New(SqlValueUtil.FromObject(value1)); var obj2 = SqlObject.New(SqlValueUtil.FromObject(value2)); var exp = SqlExpression.Binary(expressionType, SqlExpression.Constant(obj1), SqlExpression.Constant(obj2)); var sqltType = exp.Type; var wider = obj1.Type.Wider(obj2.Type); Assert.Equal(wider, sqltType); }
public static void GetConditionString(bool test, object ifTrue, object ifFalse, string expected) { var testExp = SqlExpression.Constant(SqlObject.Boolean(test)); var ifTrueExp = SqlExpression.Constant(SqlObject.New(SqlValueUtil.FromObject(ifTrue))); var ifFalseExp = SqlExpression.Constant(SqlObject.New(SqlValueUtil.FromObject(ifFalse))); var condition = SqlExpression.Condition(testExp, ifTrueExp, ifFalseExp); var sql = condition.ToString(); Assert.Equal(expected, sql); }
public static void CreateInvokeWithMixedArguments(string methodName, string argName1, object value1, object value2) { var name = ObjectName.Parse(methodName); var arg1 = SqlExpression.Constant(SqlObject.New(SqlValueUtil.FromObject(value1))); var arg2 = SqlExpression.Constant(SqlObject.New(SqlValueUtil.FromObject(value2))); var invoke = new Invoke(name); invoke.Arguments.Add(new InvokeArgument(argName1, arg1)); Assert.Throws <ArgumentException>(() => invoke.Arguments.Add(new InvokeArgument(arg2))); }
public void GetQuantifyString(SqlExpressionType expressionType, SqlExpressionType opType, string expected) { var left = SqlExpression.Constant(SqlObject.New(SqlValueUtil.FromObject(212))); var right = SqlExpression.Constant(SqlObject.New(SqlValueUtil.FromObject(array))); var binary = SqlExpression.Binary(opType, left, right); var exp = SqlExpression.Quantify(expressionType, binary); var sql = exp.ToString(); Assert.Equal(expected, sql); }