public void ParsePathArgs() { string ruleText = @"arg0='La',arg1path='Foo'"; MatchRule rule = MatchRule.Parse(ruleText); Assert.AreEqual(ruleText, rule.ToString()); }
private static (IDictionary <string, Rule>, List <string>) Parse(List <string> lines) { var rules = new Dictionary <string, Rule>(); var messages = new List <string>(); foreach (var line in lines) { if (OrRule.MatchesRuleDescription(line)) { var rule = OrRule.Parse(line); rules.Add(rule.Id, rule); } else if (MatchRule.MatchesRuleDescription(line)) { MatchRule matchRule = MatchRule.Parse(line); rules.Add(matchRule.Id, matchRule); } else if (SequenceRule.MatchesRuleDescription(line)) { SequenceRule sequenceRule = SequenceRule.Parse(line); rules.Add(sequenceRule.Id, sequenceRule); } else if (!string.IsNullOrEmpty(line)) { messages.Add(line); } } return(rules, messages); }
public void CanonicalOrdering() { string ruleText = @"arg0='La',arg5path='/bar',arg2='Fa',destination='org.ndesk.Recipient',interface='org.ndesk.ITest',arg1path='/foo'"; string sortedRuleText = @"interface='org.ndesk.ITest',destination='org.ndesk.Recipient',arg0='La',arg1path='/foo',arg2='Fa',arg5path='/bar'"; MatchRule rule = MatchRule.Parse(ruleText); Assert.AreEqual(4, rule.Args.Count); Assert.AreEqual(sortedRuleText, rule.ToString()); }
public void Parse() { string ruleText = @"member='Lala'"; MatchRule rule = MatchRule.Parse(ruleText); Assert.AreEqual(null, rule.MessageType); Assert.AreEqual(0, rule.Args.Count); Assert.AreEqual(ruleText, rule.ToString()); }
public void ParseArgs() { string ruleText = @"arg5='F,o\'o\\\'\\',arg8=''"; MatchRule rule = MatchRule.Parse(ruleText); Assert.AreEqual(null, rule.MessageType); Assert.AreEqual(2, rule.Args.Count); //Assert.AreEqual (@"F,o'o\'\", rule.Args[5].Value); //Assert.AreEqual (@"", rule.Args[8].Value); Assert.AreEqual(ruleText, rule.ToString()); }
public void ParseArgsMoreThanAllowed() { string ruleText = @"arg64='Foo'"; MatchRule.Parse(ruleText); }
public void ParseArgsMaxAllowed() { string ruleText = @"arg63='Foo'"; MatchRule.Parse(ruleText); }