Example #1
0
        public void Should_be_able_to_add_pure_expressions_as_well_for_ease()
        {
            RuleSet ruleSet = Rule.Declare <OrderSubmitted>(rule =>
            {
                rule.Then(x => Trace.WriteLine("Order Amount: " + x.Object.Amount));

                rule.When(x => x.Amount > 100.00m)
                .Then(x => Trace.WriteLine("Order is over the limit"))
                .Then(x => x.RequestApproval());

                rule.When(x => x.Amount > 1000m)
                .Then(x => x.RequestClearance());
            });

//			RuleSet ruleSet2 = Rule.Declare<OrderSubmitted>(rule =>
//				{
//					rule.When(x => x.Amount > 100.00m)
//						.Then(x => Trace.WriteLine("BING"));
//				});


            _engine.Add(ruleSet);
//			_engine.Add(ruleSet2);

            using (StatefulSession session = _engine.CreateSession())
            {
                session.Assert(new OrderSubmitted {
                    Amount = 123.45m
                });

                session.Run();
            }
        }