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); }); }
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 } }); } }
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 } }); } }
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 } }); } }
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); }); }
public override void ExitRule_item_condition(CfgGramParser.Rule_item_conditionContext context) { Condition.Values = ConditionValues.Any() ? ConditionValues.ToArray() : null; RuleItem.AddCondition(Condition); }