void ExternalVariableTest() { var srm = new ScriptRunningMachine(); srm["a"] = 10; srm.Run("var b = a + 20; "); TestCaseAssertion.AssertEquals(srm["b"], 30d); }
public void ExtendedVariableAccessor() { var srm = new ScriptRunningMachine(); var ctx = srm.CreateContext(); ctx.ExternalVariableGetter = (id) => { if (id.StartsWith("$")) { return(id.Substring(1)); } else { return(null); } }; string result = Convert.ToString(srm.CalcExpression("$A1", ctx)); TestCaseAssertion.AssertEquals(result, "A1"); }