/// <summary>Test the hard coded rules. /// One rule is testet with the load function.</summary> /// <param name="code">String to parse.</param> /// <param name="markup">Expected markup from rule output.</param> /// <param name="rules">List of rules to test. The first rule is loaded.</param> public static void ParserLoadRule(List <Rule> rules, string code, string markup) { var parser = new Parser(); var outElements = new List <TextElement>(); TextBuffer buffer = Util.NewBufferWs(code); parser.Rules = rules.Select(r => r.CloneForParse(buffer) as Rule).ToList(); ParserBuilder.InitializeGrammar(parser, parser.Rules, buffer.Status); ParserBuilder.ValidateGrammar(parser, buffer.Status); string syntax = parser.GetGrammar(); Rule rule = parser.Rules[0]; Assert.AreEqual(true, rule.Load(outElements, 0), string.Format("rule '{0}': cant read", rule.Name)); string actual = outElements[0].ToMarkupProtected(string.Empty); Assert.AreEqual(markup, actual, "Equation TestOption: document fail"); }