Exemple #1
0
        public void CorrectValue(string input, double value)
        {
            StringExpression parser = new StringExpression(input, new TokenFactory());
            var parsed    = parser.Parse();
            var evaluator = new ParsedExpression(parsed);

            Assert.Equal(value, evaluator.Evaluate());
        }
Exemple #2
0
        public void DivisionByZero(string input)
        {
            StringExpression parser = new StringExpression(input, new TokenFactory());
            var parsed    = parser.Parse();
            var evaluator = new ParsedExpression(parsed);

            Assert.Throws <ArithmeticException>(() => evaluator.Evaluate());
        }
Exemple #3
0
        public void InvalidSyntax(string input)
        {
            StringExpression parser = new StringExpression(input, new TokenFactory());

            Assert.Throws <ArgumentException>(() => parser.Parse());
        }