Example #1
0
        public void SimpleBinaryWithUnary()
        {
            var ast = new BinaryExpression
            {
                LeftOperand = new IdentifierExpression {
                    Identifier = "Latitude"
                },
                Operator     = ">=",
                RightOperand = new UnaryExpression {
                    Operator = "-", Operand = new ValueExpression {
                        Value = 22.3d
                    }
                }
            };

            ast.See("AST content");

            var xlat = new TeztXlat();
            var ctx  = xlat.TranslateInContext(ast);

            ctx.SQL.See();
            ctx.Parameters.See();

            Aver.AreEqual("(T1.\"Latitude\" >= (-??P0))", ctx.SQL.ToString());
            Aver.AreEqual("P0", ctx.Parameters.First().ParameterName);
            Aver.AreEqual(22.3d, ctx.Parameters.First().Value.AsDouble());
        }
Example #2
0
        public void SimpleBinaryWithUnaryPrimitive()
        {
            var ast = new BinaryExpression
            {
                LeftOperand = new IdentifierExpression {
                    Identifier = "Latitude"
                },
                Operator     = ">=",
                RightOperand = new UnaryExpression {
                    Operator = "-", Operand = new ValueExpression {
                        Value = 1080
                    }
                }
            };

            ast.See("AST content");

            var xlat = new TeztXlat();
            var ctx  = xlat.TranslateInContext(ast);

            ctx.SQL.See();

            Aver.AreEqual("(T1.\"Latitude\" >= (-1080))", ctx.SQL.ToString());
            Aver.IsFalse(ctx.Parameters.Any());
        }
Example #3
0
        public void SimpleBinary()
        {
            var ast = new BinaryExpression
            {
                LeftOperand = new IdentifierExpression {
                    Identifier = "Name"
                },
                Operator     = "=",
                RightOperand = new ValueExpression {
                    Value = "Kozlovich"
                }
            };

            ast.See("AST content");

            var xlat = new TeztXlat();
            var ctx  = xlat.TranslateInContext(ast);

            ctx.SQL.See();
            ctx.Parameters.See();

            Aver.AreEqual("(T1.\"Name\" = ??P0)", ctx.SQL.ToString());
            Aver.AreEqual("P0", ctx.Parameters.First().ParameterName);
            Aver.AreEqual("Kozlovich", ctx.Parameters.First().Value.AsString());
        }