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 void InvokingWithIncorrectWorkingMemoryThrowsAnException()
        {
            var rule = new Rule { Name = "First Rule", TopCondition = new LogicCondition { Operator = "all" } };
            var action1 = new AssignAction { LeftHandSide = "Person.Salutation", Value = "Mr." };
            rule.AddAction(action1);

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

            IRuleEngine engine = WFRuleEngine.Compile(rs);

            Assert.Throws(typeof(InvalidWorkflowException), delegate
            {
                engine.Invoke(_workingMemory);
            });
        }
 private Rule CreateTestRule(ExpressionCondition condition, AssignAction action)
 {
     var rule = new Rule { Name = "Rule 1", TopCondition = new LogicCondition { Operator = "all" } };
     rule.TopCondition.AddCondition(condition);
     rule.AddAction(action);
     return rule;
 }