コード例 #1
0
 public void TestPatternFail1()
 {
     SetUp();
     Link link = new Link("callingrule", "calledrule");
     Link linkdiff = new Link("callingrule", "othercalledrule");
     _links.Add(link);
     LinkExistsTest(linkdiff);
     TearDown();
 }
コード例 #2
0
 public bool CheckLinkExists(List<Link> _links, Link record)
 {
     bool exists = false;
     foreach (Link l in _links)
     {
     if (l.CallingEnt.Equals(record.CallingEnt) && l.CalledEnt.Equals(record.CalledEnt))
     {
         exists = true;
     }
     }
     return exists;
 }
コード例 #3
0
        public bool RuleInRuleMatch(string calledRule, RuleDefinition rule, List<Link> _links, bool addNotApplicable)
        {
            //line contains
            string match1 = " " + calledRule + ";";
            string match2 = " " + calledRule + "(";
            string match3 = "(" + calledRule + ";";
            string match4 = "(" + calledRule + "(";
            string match7 = "(" + calledRule + ")";
            string match10 = "= " + calledRule + "(";
            string match24 = "= " + calledRule + ";";
            string match11 = "^= " + calledRule + "(";
            string match25 = "^= " + calledRule + ";";
            string match15 = "> " + calledRule + "(";
            string match27 = "> " + calledRule + ";";
            string match16 = "=> " + calledRule + "(";
            string match28 = "=> " + calledRule + ";";
            string match19 = "< " + calledRule + "(";
            string match29 = "< " + calledRule + ";";
            string match20 = "<= " + calledRule + "(";
            string match30 = "<= " + calledRule + ";";
            string match21 = "(" + calledRule + ",";
            string match22 = ", " + calledRule + ", ";
            string match23 = ", " + calledRule + ")";

            //line starts with
            string match5 = calledRule + "(";
            string match6 = calledRule + ";";
            string match8 = calledRule + " =";
            string match9 = calledRule + " ^=";
            string match13 = calledRule + " >";
            string match14 = calledRule + " =>";
            string match17 = calledRule + " <";
            string match18 = calledRule + " <=";
            string match12 = "^" + calledRule + "(";
            string match26 = "^" + calledRule + ";";

            //donot add a rule if it matches the following string patterns, as they are signals.
            string signal1 = "SIGNAL " + calledRule + ";";
            string signal2 = "ON " + calledRule + ";";
            string signal3 = "UNTIL " + calledRule + ";";

            string line = rule.Body;

            if (!line.Contains(signal1) && !line.Contains(signal2) && !line.Contains(signal3))
            {
                if (line.Contains(match1) || line.Contains(match2) || line.Contains(match3) || line.Contains(match4) || line.Contains(match7) || line.Contains(match10) || line.Contains(match11) || line.Contains(match15) || line.Contains(match16) || line.Contains(match19) || line.Contains(match20) || line.Contains(match21) || line.Contains(match22) || line.Contains(match23) || line.Contains(match24) || line.Contains(match25) || line.Contains(match27) || line.Contains(match28) || line.Contains(match29) || line.Contains(match30) || line.StartsWith(match13) || line.StartsWith(match14) || line.StartsWith(match5) || line.StartsWith(match6) || line.StartsWith(match8) || line.StartsWith(match9) || line.StartsWith(match12) || line.StartsWith(match17) || line.StartsWith(match18) || line.StartsWith(match26))
                {
                    Link record = new Link(rule.Name.ToString(), calledRule);

                    bool exists = CheckLinkExists(_links, record);

                    if (!exists)
                    {
                        _links.Add(record);
                        addNotApplicable = false;
                    }

                }
            }
            return addNotApplicable;
        }
コード例 #4
0
        public void TriggerInRuleMatch(TriggerDefinition trigger, RuleDefinition rule, List<Link> _links)
        {
            List<string> matches = new List<string>();

            //Build up list of stirng pattern matches based on trigger access code
            matches = TriggerCodeConversion(trigger, matches);

            foreach (string s in matches)
            {
            if (rule.Body.StartsWith(s))
            {
                string triggerName = trigger.TableName.ToString() + ", " + trigger.RuleName.ToString() + ", " + trigger.Access.ToString();
                Link record = new Link(rule.Name, triggerName);
                bool exists = CheckLinkExists(_links, record);

                if (!exists)
                {
                    _links.Add(record);
                }
            }
            }
        }
コード例 #5
0
        public bool TableInRuleMatch(string calledTable, RuleDefinition rule, List<Link> _links)
        {
            string match1 = " " + calledTable + ";";
            string match2 = " " + calledTable + "(";
            string match3 = " " + calledTable + " ";
            string match4 = calledTable + ".";
            string match5 = "'" + calledTable + "'";

            if (rule.Body.Contains(match1) || rule.Body.Contains(match2) || rule.Body.Contains(match3) || rule.Body.Contains(match4) || rule.Body.Contains(match5))
            {
            Link record = new Link(rule.Name.ToString(), calledTable);

            bool exists = CheckLinkExists(_links, record);
            if (!exists)
            {
                _links.Add(record);
                return true; // no need to loop any more
            }
            else
            {
                return false;
            }
            }
            else
            {
            return false;
            }
        }
コード例 #6
0
 private void LinkExistsTest(Link link)
 {
     //call the method with the rule pattern matching for each pattern
     added = i.CheckLinkExists(_links, link);
     Assert.AreEqual(true, added);
 }