Пример #1
0
        public void Only_those_that_are_matched_should_be_called()
        {
            var junction = new JoinNode <Customer>(_constantNode);

            junction.AddSuccessor(_actionNode);

            var alphaNodeA = new AlphaNode <Customer>();

            alphaNodeA.AddSuccessor(junction);

            var joinJunction = new JoinNode <Customer>(alphaNodeA);

            var alphaNodeB = new AlphaNode <Customer>();

            alphaNodeB.AddSuccessor(joinJunction);

            var actionNode = new ActionNode <Customer>(x => _secondaryCalled.Complete(x.Element.Object));

            var joinJunction2 = new JoinNode <Customer>(alphaNodeA);

            joinJunction2.AddSuccessor(actionNode);

            var alphaNodeC = new AlphaNode <Customer>();

            alphaNodeC.AddSuccessor(joinJunction2);

            var tree = new TypeNode <Customer>();

            var isPreferred = new ConditionNode <Customer>(x => x.Preferred);

            isPreferred.AddSuccessor(alphaNodeA);

            tree.AddSuccessor(isPreferred);

            tree.AddSuccessor(alphaNodeB);

            var isActive = new ConditionNode <Customer>(x => x.Active);

            isActive.AddSuccessor(alphaNodeC);
            tree.AddSuccessor(isActive);

            var visitor = new StringNodeVisitor();

            tree.Visit(visitor);

            Trace.WriteLine(visitor.Result);



            tree.Activate(_context);
            _session.Run();

            _primaryCalled.IsCompleted.ShouldBeTrue();
            _secondaryCalled.IsCompleted.ShouldBeFalse();
        }
Пример #2
0
        public void Only_those_that_are_matched_should_be_called()
        {
            var junction = new JoinNode<Customer>(_constantNode);
            junction.AddSuccessor(_actionNode);

            var alphaNodeA = new AlphaNode<Customer>();
            alphaNodeA.AddSuccessor(junction);

            var joinJunction = new JoinNode<Customer>(alphaNodeA);

            var alphaNodeB = new AlphaNode<Customer>();
            alphaNodeB.AddSuccessor(joinJunction);

            var actionNode = new ActionNode<Customer>(x => _secondaryCalled.Complete(x.Element.Object));

            var joinJunction2 = new JoinNode<Customer>(alphaNodeA);
            joinJunction2.AddSuccessor(actionNode);

            var alphaNodeC = new AlphaNode<Customer>();
            alphaNodeC.AddSuccessor(joinJunction2);

            var tree = new TypeNode<Customer>();

            var isPreferred = new ConditionNode<Customer>(x => x.Preferred);
            isPreferred.AddSuccessor(alphaNodeA);

            tree.AddSuccessor(isPreferred);

            tree.AddSuccessor(alphaNodeB);

            var isActive = new ConditionNode<Customer>(x => x.Active);
            isActive.AddSuccessor(alphaNodeC);
            tree.AddSuccessor(isActive);

            var visitor = new StringNodeVisitor();
            tree.Visit(visitor);

            Trace.WriteLine(visitor.Result);

            tree.Activate(_context);
            _session.Run();

            _primaryCalled.IsCompleted.ShouldBeTrue();
            _secondaryCalled.IsCompleted.ShouldBeFalse();
        }