RulesEngineGraph CreateRulesEngineGraph(RulesEngine machine)
        {
            var visitor = new GraphRulesEngineVisitor();

            machine.Accept(visitor);

            return(visitor.Graph);
        }
示例#2
0
        public static void ShowVisualizer(this RulesEngine engine)
        {
            var visitor = new GraphRulesEngineVisitor();

            engine.Accept(visitor);

            RulesEngineGraph graph = visitor.Graph;

            RulesEngineDebugVisualizer.Show(graph);
        }
        public void Should_not_activate_for_only_other_side()
        {
            _result = null;

            RulesEngine rulesEngine = RulesEngineFactory.New(x => { x.Add(_rule); });

            using (Session session = rulesEngine.CreateSession())
            {
                session.Add(new Order {
                    Name = "MAMA", Amount = 10001.0m
                });
                session.Run();
            }

            var visitor = new TextRuntimeVisitor();

            rulesEngine.Accept(visitor);

            Console.WriteLine(visitor);

            Assert.IsNull(_result);
        }
        public void Should_compile_and_execute()
        {
            _result = null;

            RulesEngine rulesEngine = RulesEngineFactory.New(x => { x.Add(_rule); });

            using (Session session = rulesEngine.CreateSession())
            {
                session.Add(new Order {
                    Name = "JOE", Amount = 10001.0m
                });
                session.Run();
            }

            var visitor = new TextRuntimeVisitor();

            rulesEngine.Accept(visitor);

            Console.WriteLine(visitor);

            Assert.IsNotNull(_result);
            Assert.IsNotNull(_resultB);
        }