Exemplo n.º 1
0
        public void ParsePathArgs()
        {
            string    ruleText = @"arg0='La',arg1path='Foo'";
            MatchRule rule     = MatchRule.Parse(ruleText);

            Assert.AreEqual(ruleText, rule.ToString());
        }
Exemplo n.º 2
0
        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);
        }
Exemplo n.º 3
0
        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());
        }
Exemplo n.º 4
0
        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());
        }
Exemplo n.º 5
0
        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());
        }
Exemplo n.º 6
0
        public void ParseArgsMoreThanAllowed()
        {
            string ruleText = @"arg64='Foo'";

            MatchRule.Parse(ruleText);
        }
Exemplo n.º 7
0
        public void ParseArgsMaxAllowed()
        {
            string ruleText = @"arg63='Foo'";

            MatchRule.Parse(ruleText);
        }