public void ExpressionInterpreterTest() { var actual = ExpressionInterpreter.Compute(Parser.Parse("- 2 * z / Math.Pow(2, x * PI)"), new[] { new ExpressionParameter("x", 1.0), new ExpressionParameter("z", 2.0), new ExpressionParameter("PI", Math.PI), }, (name, parameters) => { switch (name) { case "Math.Pow": { var args = parameters.Select(Convert.ToDouble).ToList(); if (args.Count != 2) { throw new InvalidOperationException("Wrong number of arguments passed to Math.Pow. Expected (double x, double y)"); } return((decimal)Math.Pow(args[0], args[1])); } default: throw new NotSupportedException(string.Format("Function is not supported: {0}", name)); } }); Assert.AreEqual(-0.4532589291870443972585070297m, actual); }