public void RuleSetIsValidIfRulesAreValid()
        {
            var rule = new Rule { Name = "First Rule", TopCondition = new LogicCondition { Operator = "all" } };
            var action1 = new AssignAction { LeftHandSide = "Person.Salutation", Value = "Mr." };
            var action2 = new AssignAction { LeftHandSide = "Person.Greeting", Value = "Hello" };
            rule.AddAction(action1);
            rule.AddAction(action2);

            var rs = new RuleSet { Name = "Whatever" };
            rs.AddInput("Person", typeof(TestPerson));
            rs.AddRule(rule);

            Assert.IsTrue(rs.IsValid());
        }
 public static WFRuleEngine Compile(RuleSet ruleSet)
 {
     if (ruleSet.IsValid())
     {
         var activity = new DynamicActivity();
         CompileInputs(activity, ruleSet);
         var implementation = CompileRules(ruleSet);
         activity.Implementation = () => implementation;
         return new WFRuleEngine(activity);
     }
     else
     {
         throw new Exception("RuleSet cannot be compiled.");
     }
 }
 public void RuleSetWithoutNameIsInvalid()
 {
     var rs = new RuleSet();
     Assert.IsFalse(rs.IsValid());
 }
 public void EmptyRuleSetIsValid()
 {
     var rs = new RuleSet { Name = "Whatever" };
     Assert.IsTrue(rs.IsValid());
 }