コード例 #1
0
ファイル: TestParser.cs プロジェクト: dloney/Pisces
        public void StringParameter()
        {
            string expression = "HydrometRuleCurve(\"c:\\temp\\prvo\",fc))";

            string         subExpression;
            ParserFunction f;

            ParserUtility.TryGetFunctionCall(expression, out subExpression, out f);

            Assert.AreEqual("HydrometRuleCurve", f.Name);
            Assert.AreEqual(2, f.Parameters.Length);

            Assert.AreEqual("\"c:\\temp\\prvo\"", f.Parameters[0]);
            Assert.AreEqual("fc", f.Parameters[1]);

            CalculationSeries cs = new CalculationSeries("test");

            cs.Expression = expression;
            var vars = cs.GetDependentVariables();

            // "prvo"  is a string NOT a variable.
            foreach (var item in vars)
            {
                System.Console.WriteLine("'" + item + "'");
            }

            Assert.IsTrue(vars.Count == 1, "string parameter is not a variable");

            Assert.IsTrue(vars[0] == "fc");
        }