public void IfTest() { StandardParser formula = new StandardParser("if(7==8,0,1)"); decimal result = formula.Solve <decimal>(new StandardVariableCollection()); Assert.AreEqual(result, Convert.ToDecimal(1)); }
public void BasicNegativeTest() { StandardParser formula = new StandardParser("(7+6)+-4"); decimal compare = (Convert.ToDecimal(7) + Convert.ToDecimal(6)) + Convert.ToDecimal(-4); decimal result = formula.Solve <decimal>(new StandardVariableCollection()); Assert.AreEqual(compare, result); }
public void DoubleSubtractionTest() { StandardParser formula = new StandardParser("10-0-200"); decimal compare = Convert.ToDecimal(10) - Convert.ToDecimal(0) - Convert.ToDecimal(200); decimal result = formula.Solve <decimal>(new StandardVariableCollection()); Assert.AreEqual(compare, result); }
public void TestVariable() { StandardParser parser = new StandardParser("so91"); decimal val = 453.444m; StandardVariableCollection vars = new StandardVariableCollection(); vars.Add("so91", val); Assert.AreEqual(val, parser.Solve <decimal>(vars)); }
public void ConditionNegativeTest() { StandardParser formula = new StandardParser("a<=-0.12"); decimal compare = Convert.ToDecimal(10) - Convert.ToDecimal(0) - Convert.ToDecimal(200); StandardVariableCollection vars = new StandardVariableCollection(); vars.Add("a", -111m); Assert.IsTrue(formula.Solve <bool>(vars)); }
public void EqualsNullTest() { StandardParser formula = new StandardParser("a==null"); decimal compare = Convert.ToDecimal(10) - Convert.ToDecimal(0) - Convert.ToDecimal(200); StandardVariableCollection vars = new StandardVariableCollection(); vars.Add("a", null); Assert.IsTrue(formula.Solve <bool>(vars)); }
public void TestMissingVariable() { StandardParser parser = new StandardParser("so91>so92"); parser.OnSolveError += parser_OnSolveError; decimal val = 453.444m; StandardVariableCollection vars = new StandardVariableCollection(); vars.Add("so91", val); vars.Add("so92", "'a'"); Assert.AreEqual(val, parser.Solve <decimal>(vars)); }