public void ParseAndEvaluateTest() { ScriptVariables var = new ScriptVariables() { Round = 5 }; string script = @"1)4/6/10 4)4/8/8"; WeblScript wScript = new WeblScript(); string expected = "4/8/8"; string actual = wScript.ParseAndEvaluate(script, var).Text; Assert.AreEqual(expected, actual); }
private FighterRoundPlan EvaluatePlan(FightRoundVariables frv) { if (WeblScript == null) { WeblScript = new WeblScript(); } ScriptVariables variables = frv.ToScriptVariables(); ParseResult res = WeblScript.ParseAndEvaluate(this.FightPlanText, variables); FighterRoundPlan roundPlan = FighterRoundPlan.Parse(res.Text); if (res.Cheat) { roundPlan.Dirty = true; } roundPlan.HitLineNumber = res.LineNumber; return(roundPlan); }
public void TestCheat() { ScriptVariables var = new ScriptVariables() { Round = 5 }; string script = @"1)4/6/10 4)4/8/8 if warnings < 1 then cheat if warnings < 1 then 5/7/8"; WeblScript wScript = new WeblScript(); string expected = "4/8/8"; ParseResult ret = wScript.ParseAndEvaluate(script, var); Assert.IsTrue(ret.Cheat); Assert.AreEqual("5/7/8", ret.Text); }