Beispiel #1
0
 public void WrongConditionArgArray()
 {
     Assert.Throws <WrongConditionArgsException>(() =>
     {
         var item  = new RuleItem();
         item.Type = RuleItemType.Terminal;
         item.Key  = "123";
         item.AddCondition(new Condition("морф", false));
         var rezCond = _manager.GetCondition(item);
     });
 }
Beispiel #2
0
 public void EndText()
 {
     foreach (var condKey in new[] { "конец", "end" })
     {
         var item = new RuleItem();
         item.Type = RuleItemType.Terminal;
         item.Key  = "123";
         item.AddCondition(new Condition(condKey, false));
         check(item, new Dictionary <Token, bool>()
         {
             { new Token("123", 2, 5, 8, new TextInfo(3, 8)), true },
             { new Token("123", 1, 2, 3, new TextInfo(5, 8)), false }
         });
     }
 }
Beispiel #3
0
 public void StartText()
 {
     foreach (var condKey in new[] { "начало", "start" })
     {
         var item = new RuleItem();
         item.Type = RuleItemType.Terminal;
         item.Key  = "123";
         item.AddCondition(new Condition(condKey, false));
         check(item, new Dictionary <Token, bool>()
         {
             { new Token("123", 0, 0, 3, null), true },
             { new Token("123", 1, 2, 3, null), false }
         });
     }
 }
Beispiel #4
0
 public void StartsUpper()
 {
     foreach (var condKey in new[] { "нбол", "sbig" })
     {
         var item = new RuleItem();
         item.Type = RuleItemType.Regex;
         item.Key  = ".*";
         item.AddCondition(new Condition(condKey, false));
         check(item, new Dictionary <Token, bool>()
         {
             { new Token("ТЕСТ"), true },
             { new Token("Тест"), true },
             { new Token("тест"), false }
         });
     }
 }
Beispiel #5
0
        public void WrongConditionArgString()
        {
            Assert.Throws <WrongConditionArgsException>(() =>
            {
                var item  = new RuleItem();
                item.Type = RuleItemType.Terminal;
                item.Key  = "123";
                item.AddCondition(new Condition("рег", false));
                var rezCond = _manager.GetCondition(item);
            });

            Assert.Throws <WrongConditionArgsException>(() =>
            {
                var item  = new RuleItem();
                item.Type = RuleItemType.Terminal;
                item.Key  = "123";
                item.AddCondition(new Condition("рег", new [] { "123", "123" }));
                var rezCond = _manager.GetCondition(item);
            });
        }
Beispiel #6
0
 public override void ExitRule_item_condition(CfgGramParser.Rule_item_conditionContext context)
 {
     Condition.Values = ConditionValues.Any() ? ConditionValues.ToArray() : null;
     RuleItem.AddCondition(Condition);
 }