Ejemplo n.º 1
0
        public void TestReservedKeywordsWrongUsage()
        {
            TestMetadataResolver metadataResolver = new TestMetadataResolver();
            string     expression = "VAR(SYSTIME_YMD)-$FIELD(DATFLD1)";
            Calculator calc       = new Calculator(metadataResolver);

            Assert.Throws <ExpressionException>(() => calc.Calculate(expression));
        }
Ejemplo n.º 2
0
        public void TestCalculatorWithDateResult(string expression, string expectedResult)
        {
            TestMetadataResolver metadataResolver = new TestMetadataResolver();
            Calculator           calc             = new Calculator(metadataResolver);

            Argument result = calc.Calculate(expression);

            Assert.True(result.IsDate);
            Assert.AreEqual(expectedResult, result.ToDate().Value.ToString("yyyy-MM-dd"));
        }
Ejemplo n.º 3
0
        public void TestCalculatorWithIntegerResult(string expression, int expectedResult)
        {
            TestMetadataResolver metadataResolver = new TestMetadataResolver();
            Calculator           calc             = new Calculator(metadataResolver);

            Argument result = calc.Calculate(expression);

            Assert.True(result.IsInteger);
            Assert.AreEqual(expectedResult, result.ToInteger());
        }
Ejemplo n.º 4
0
        public void TestCalculatorWithDoubleResult(string expression, double expectedResult)
        {
            TestMetadataResolver metadataResolver = new TestMetadataResolver();
            Calculator           calc             = new Calculator(metadataResolver);

            Argument result = calc.Calculate(expression);

            Assert.True(result.IsDouble);
            Assert.AreEqual(expectedResult, result.ToDouble(), 1e-10);
        }
Ejemplo n.º 5
0
        public void TestNormdFirebird(string expr, string expectedQuery)
        {
            Setup(expr);

            CalcParser.ExpressionContext context = this._calcParser.expression();
            DbTranslator      translator         = new FirebirdTranslator();
            IMetadataResolver resolver           = new TestMetadataResolver();

            QueryVisitor visitor = new QueryVisitor(resolver, translator);
            string       query   = visitor.Visit(context);

            Assert.AreEqual(expectedQuery, query);
        }