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)); }
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")); }
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()); }
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); }
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); }