Ejemplo n.º 1
0
        public void OneWordGrammarNestedInSequenceGrouping()
        {
            var rule = _factory.Create();

            rule.Say("test");

            Assert.That(rule.Elements, Is.InstanceOf <ISequence>());
            Assert.That(rule.Elements.Elements.First(), Is.InstanceOf <IWordElement>());
        }
Ejemplo n.º 2
0
 private Distinctions GetDifference <T>(T expected, T actual, string propertyName) =>
 RuleFactory
 .Create(RuleForCollectionTypes, RuleForReferenceTypes, RuleForValuesTypes)
 .GetFor(actual.GetType())
 .Compare(expected, actual, propertyName);
        public void CheckRuleTrue()
        {
            var ruleTrue = _ruleFactory.Create(c => c.Id == 1);

            Assert.True(ruleTrue.Check(_identity));
        }
Ejemplo n.º 4
0
 public void AddRule(String name, Func <IRule, IRule> ruleFunc) =>
 AddRule(name, ruleFunc?.Invoke(RuleFactory.Create()));
Ejemplo n.º 5
0
 public void IfArgumentToCreateFunctionNullReferenceThenThrowException()
 {
     Assert.Throws <ArgumentNullException>(() => _ruleFactory.Create(null));
 }
Ejemplo n.º 6
0
        public IRule Translate(RuleData ruleData)
        {
            if (ruleData == null)
            {
                throw new ArgumentNullException("ruleData");
            }

            RuleOperator ruleOperator;
            var          rule = Enum.TryParse(ruleData.RuleOperator, false, out ruleOperator) ? _factory.Create(ruleOperator, ruleData.Field, ruleData.Value) : NullRule;

            rule.ValidationMessage = ruleData.ValidationMessage;
            return(rule);
        }