Esempio n. 1
0
        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));
        }
Esempio n. 2
0
        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);
        }
Esempio n. 3
0
        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);
        }
Esempio n. 4
0
        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));
        }
Esempio n. 5
0
        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));
        }
Esempio n. 6
0
        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));
        }
Esempio n. 7
0
        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));
        }