public void TestCombinationsOfAnd() { TemplateUtil.EvaluateBooleanCondition(true, "{V} > \"10\" AND {X} IN {Xs} AND {Y} + \"42\" < \"3\" * \"21\" - {Z}", new Dictionary <string, string> { { "V", "42" }, { "X", "Hello" }, { "Y", "3" }, { "Z", "6" } }, new Dictionary <string, IEnumerable <string> > { { "Xs", new[] { "Hi", "Hello", "Hey" } } } ); TemplateUtil.EvaluateBooleanCondition(false, "{V} > \"10\" AND {X} IN {Xs} AND {Y} + \"42\" < \"3\" * \"21\" - {Z}", new Dictionary <string, string> { { "V", "3" }, { "X", "Hello" }, { "Y", "3" }, { "Z", "6" } }, new Dictionary <string, IEnumerable <string> > { { "Xs", new[] { "Hi", "Hello", "Hey" } } } ); TemplateUtil.EvaluateBooleanCondition(false, "{V} > \"10\" AND {X} IN {Xs} AND {Y} + \"42\" < \"3\" * \"21\" - {Z}", new Dictionary <string, string> { { "V", "42" }, { "X", "GoodBye" }, { "Y", "3" }, { "Z", "6" } }, new Dictionary <string, IEnumerable <string> > { { "Xs", new[] { "Hi", "Hello", "Hey" } } } ); TemplateUtil.EvaluateBooleanCondition(false, "{V} > \"10\" AND {X} IN {Xs} AND {Y} + \"42\" < \"3\" * \"21\" - {Z}", new Dictionary <string, string> { { "V", "42" }, { "X", "Hello" }, { "Y", "42" }, { "Z", "6" } }, new Dictionary <string, IEnumerable <string> > { { "Xs", new[] { "Hi", "Hello", "Hey" } } } ); TemplateUtil.EvaluateBooleanCondition(false, "{V} > \"10\" AND {X} IN {Xs} AND {Y} + \"42\" < \"3\" * \"21\" - {Z}", new Dictionary <string, string> { { "V", "3" }, { "X", "GoodBye" }, { "Y", "42" }, { "Z", "6" } }, new Dictionary <string, IEnumerable <string> > { { "Xs", new[] { "Hi", "Hello", "Hey" } } } ); }
public void TestForLoop() { string expected = string.Concat(Enumerable.Range(0, 20).Select(x => x.ToString())); TemplateUtil.EvaluateFor(expected, "{I} FROM \"0\" TO \"19\"", "{I}", new Dictionary <string, string>()); TemplateUtil.EvaluateFor(expected, "{I} FROM \"0\" UNTIL \"20\"", "{I}", new Dictionary <string, string>()); TemplateUtil.EvaluateFor(expected, "{I} FROM \"0\" TO \"20\" - \"1\"", "{I}", new Dictionary <string, string>()); TemplateUtil.EvaluateFor(expected, "{I} FROM \"0\" UNTIL \"19\" + \"1\"", "{I}", new Dictionary <string, string>()); TemplateUtil.EvaluateFor(expected, "{I} FROM \"1\" - \"1\" TO \"19\"", "{I}", new Dictionary <string, string>()); TemplateUtil.EvaluateFor(expected, "{I} FROM \"1\" - \"1\" UNTIL \"20\"", "{I}", new Dictionary <string, string>()); TemplateUtil.EvaluateFor(expected, "{I} FROM {MIN} TO \"19\"", "{I}", new Dictionary <string, string> { { "MIN", "0" } }); TemplateUtil.EvaluateFor(expected, "{I} FROM {MIN} UNTIL \"20\"", "{I}", new Dictionary <string, string> { { "MIN", "0" } }); TemplateUtil.EvaluateFor(expected, "{I} FROM {MIN} TO \"20\" - \"1\"", "{I}", new Dictionary <string, string> { { "MIN", "0" } }); TemplateUtil.EvaluateFor(expected, "{I} FROM {MIN} UNTIL \"19\" + \"1\"", "{I}", new Dictionary <string, string> { { "MIN", "0" } }); TemplateUtil.EvaluateFor(expected, "{I} FROM {MIN} - \"1\" TO \"19\"", "{I}", new Dictionary <string, string> { { "MIN", "1" } }); TemplateUtil.EvaluateFor(expected, "{I} FROM {MIN} - \"1\" UNTIL \"20\"", "{I}", new Dictionary <string, string> { { "MIN", "1" } }); TemplateUtil.EvaluateFor(expected, "{I} FROM \"0\" TO {MAX}", "{I}", new Dictionary <string, string> { { "MAX", "19" } }); TemplateUtil.EvaluateFor(expected, "{I} FROM \"0\" UNTIL {MAX}", "{I}", new Dictionary <string, string> { { "MAX", "20" } }); TemplateUtil.EvaluateFor(expected, "{I} FROM \"0\" TO {MAX} - \"1\"", "{I}", new Dictionary <string, string> { { "MAX", "20" } }); TemplateUtil.EvaluateFor(expected, "{I} FROM \"0\" UNTIL {MAX} + \"1\"", "{I}", new Dictionary <string, string> { { "MAX", "19" } }); TemplateUtil.EvaluateFor(expected, "{I} FROM \"1\" - \"1\" TO {MAX}", "{I}", new Dictionary <string, string> { { "MAX", "19" } }); TemplateUtil.EvaluateFor(expected, "{I} FROM \"1\" - \"1\" UNTIL {MAX}", "{I}", new Dictionary <string, string> { { "MAX", "20" } }); TemplateUtil.EvaluateFor(expected, "{I} FROM \"0\" TO \"20\" - {OFFSET}", "{I}", new Dictionary <string, string> { { "OFFSET", "1" } }); TemplateUtil.EvaluateFor(expected, "{I} FROM \"0\" UNTIL \"19\" + {OFFSET}", "{I}", new Dictionary <string, string> { { "OFFSET", "1" } }); TemplateUtil.EvaluateFor(expected, "{I} FROM \"1\" - {OFFSET} TO \"19\"", "{I}", new Dictionary <string, string> { { "OFFSET", "1" } }); TemplateUtil.EvaluateFor(expected, "{I} FROM \"1\" - {OFFSET} UNTIL \"20\"", "{I}", new Dictionary <string, string> { { "OFFSET", "1" } }); TemplateUtil.EvaluateFor(expected, "{I} FROM {MIN} TO {MAX}", "{I}", new Dictionary <string, string> { { "MIN", "0" }, { "MAX", "19" } }); TemplateUtil.EvaluateFor(expected, "{I} FROM {MIN} UNTIL {MAX}", "{I}", new Dictionary <string, string> { { "MIN", "0" }, { "MAX", "20" } }); TemplateUtil.EvaluateFor(expected, "{I} FROM {MIN} TO {MAX} - {OFFSET}", "{I}", new Dictionary <string, string> { { "MIN", "0" }, { "MAX", "20" }, { "OFFSET", "1" } }); TemplateUtil.EvaluateFor(expected, "{I} FROM {MIN} UNTIL {MAX} + {OFFSET}", "{I}", new Dictionary <string, string> { { "MIN", "0" }, { "MAX", "19" }, { "OFFSET", "1" } }); TemplateUtil.EvaluateFor(expected, "{I} FROM {MIN} - {OFFSET} TO {MAX}", "{I}", new Dictionary <string, string> { { "MIN", "1" }, { "MAX", "19" }, { "OFFSET", "1" } }); TemplateUtil.EvaluateFor(expected, "{I} FROM {MIN} - {OFFSET} UNTIL {MAX}", "{I}", new Dictionary <string, string> { { "MIN", "1" }, { "MAX", "20" }, { "OFFSET", "1" } }); }
public void TestTrue() { TemplateUtil.EvaluateBooleanCondition(true, "{V}", new Dictionary <string, string> { { "V", "True" } }); }