public void Test_OneStrategy_OneTraceStep()
        {
            //strategy1 : 1+1->2
            var expr1 = new Term(Expression.Add, new List<object>{1,1});
            var ts = new TraceStep(expr1, 2, "null", "meta-rule todo", "rule todo");
            var tsExpr = new TraceStepExpr(ts);
            var lst = new List<TraceStepExpr>() { tsExpr};
            var tuple = new Tuple<object, object>("strategy1", lst);
            var lstStrategy = new List<Tuple<object, object>>();
            lstStrategy.Add(tuple);

            var graph = new BehaviorGraph();
            graph.Insert(lstStrategy);            
            Assert.True(graph.Nodes.Count == 2);

            var node0 = graph.Nodes[0];
            Assert.Null(node0.SubGraph);
            var node1 = graph.Nodes[1];

            Assert.True(node0.OutEdges.Count == 1);
            var edgeInfo = node0.OutEdges[0].Property as OuterLoopEdgeProperty;
            Assert.NotNull(edgeInfo);
            Assert.True(edgeInfo.Strategy.Equals("strategy1"));

            Assert.NotNull(node1.SubGraph);
            Assert.True(node1.InEdges.Count == 1);
            Assert.True(node1.OutEdges.Count == 0);

            Assert.True(node1.SubGraph.Nodes.Count == 2);

            /////////////////////////////////////////////////////
            //Search Test

            var initNode = graph.RetrieveInitInnerNode();
            Assert.NotNull(initNode);
            int count = graph.PathFinding(initNode);
            Assert.True(count == 1);

            var nextObj = graph.SearchNextInnerLoopNode(initNode);
            var tuple2 = nextObj as Tuple<object,object>;
            Assert.NotNull(tuple2);
            var nextNode = tuple2.Item2 as BehaviorGraphNode;
            Assert.NotNull(nextNode);
            count = graph.PathFinding(nextNode);
            Assert.True(count == 0);

            var prevObj = graph.SearchPrevInnerLoopNode(nextNode) as BehaviorGraphNode;
            Assert.NotNull(prevObj);
            count = graph.PathFinding(prevObj);
            Assert.True(count == 1);
        }
        public void Test_OneStrategy_OneTraceStep()
        {
            //strategy1 : 1+1->2
            var expr1 = new Term(Expression.Add, new List <object> {
                1, 1
            });
            var ts     = new TraceStep(expr1, 2, "null", "meta-rule todo", "rule todo");
            var tsExpr = new TraceStepExpr(ts);
            var lst    = new List <TraceStepExpr>()
            {
                tsExpr
            };
            var tuple       = new Tuple <object, object>("strategy1", lst);
            var lstStrategy = new List <Tuple <object, object> >();

            lstStrategy.Add(tuple);

            var graph = new BehaviorGraph();

            graph.Insert(lstStrategy);
            Assert.True(graph.Nodes.Count == 2);

            var node0 = graph.Nodes[0];

            Assert.Null(node0.SubGraph);
            var node1 = graph.Nodes[1];

            Assert.True(node0.OutEdges.Count == 1);
            var edgeInfo = node0.OutEdges[0].Property as OuterLoopEdgeProperty;

            Assert.NotNull(edgeInfo);
            Assert.True(edgeInfo.Strategy.Equals("strategy1"));

            Assert.NotNull(node1.SubGraph);
            Assert.True(node1.InEdges.Count == 1);
            Assert.True(node1.OutEdges.Count == 0);

            Assert.True(node1.SubGraph.Nodes.Count == 2);

            /////////////////////////////////////////////////////
            //Search Test

            var initNode = graph.RetrieveInitInnerNode();

            Assert.NotNull(initNode);
            int count = graph.PathFinding(initNode);

            Assert.True(count == 1);

            var nextObj = graph.SearchNextInnerLoopNode(initNode);
            var tuple2  = nextObj as Tuple <object, object>;

            Assert.NotNull(tuple2);
            var nextNode = tuple2.Item2 as BehaviorGraphNode;

            Assert.NotNull(nextNode);
            count = graph.PathFinding(nextNode);
            Assert.True(count == 0);

            var prevObj = graph.SearchPrevInnerLoopNode(nextNode) as BehaviorGraphNode;

            Assert.NotNull(prevObj);
            count = graph.PathFinding(prevObj);
            Assert.True(count == 1);
        }
        public void Test_MultiStrategy_1()
        {
            //strategy1: 1->2, 2->3
            var ts1 = new TraceStep(1, 2, "null", "TODO1", "TODO2");
            var ts1Expr = new TraceStepExpr(ts1);
            var ts2 = new TraceStep(2, 3, "null", "TODO2", "TODO3");
            var ts2Expr = new TraceStepExpr(ts2);
            var lst1 = new List<TraceStepExpr>() { ts1Expr, ts2Expr };
            var tuple1 = new Tuple<object, object>("strategy1", lst1);

            //strategy2: 2->3, 3->5, 5->7
            var ts3 = new TraceStep(2, 3, null, "TODO", "TODO1");
            var ts3Expr = new TraceStepExpr(ts3);
            var ts4 = new TraceStep(3, 5, null, "TODO2", "TODO5");
            var ts4Expr = new TraceStepExpr(ts4);
            var ts5 = new TraceStep(5, 7, null,"Test1", "test23");
            var ts5Expr = new TraceStepExpr(ts5);
            var lst2 = new List<TraceStepExpr>() {ts3Expr, ts4Expr, ts5Expr};
            var tuple2 = new Tuple<object, object>("strategy2", lst2);

            var lstStrategy = new List<Tuple<object, object>>();
            lstStrategy.Add(tuple1);
            lstStrategy.Add(tuple2);

            var graph = new BehaviorGraph();
            graph.Insert(lstStrategy);
            Assert.True(graph.Nodes.Count == 3);

            var node1 = graph.Nodes[1];
            Assert.True(node1.OutEdges.Count == 1);
            var node2 = graph.Nodes[2];
            Assert.True(node2.InEdges.Count == 1);
            Assert.True(node2.OutEdges.Count == 0);

            Assert.NotNull(node1.SubGraph);
            Assert.True(node1.SubGraph.Nodes.Count == 3);

            Assert.NotNull(node2.SubGraph);
            Assert.True(node2.SubGraph.Nodes.Count == 4);

            /////////////////////////////////////////////////////
            //Search Test

            var initNode = graph.RetrieveInitInnerNode();
            Assert.NotNull(initNode);
            int count = graph.PathFinding(initNode);
            Assert.True(count == 5);

            var nextObj = graph.SearchNextInnerLoopNode(initNode);
            var tuple5 = nextObj as Tuple<object, object>;
            Assert.NotNull(tuple5);
            var nextNode = tuple5.Item2 as BehaviorGraphNode;
            Assert.NotNull(nextNode);
            count = graph.PathFinding(nextNode);
            Assert.True(count == 4);

            nextObj = graph.SearchNextInnerLoopNode(nextNode);
            tuple5 = nextObj as Tuple<object, object>;
            Assert.NotNull(tuple5);
            nextNode = tuple5.Item2 as BehaviorGraphNode;
            Assert.NotNull(nextNode);
            count = graph.PathFinding(nextNode);
            Assert.True(count == 3);

            var index = graph.SearchOuterLoopNodeIndex(nextNode);
            Assert.True(index == 1);

            nextObj = graph.SearchNextInnerLoopNode(nextNode);
            tuple5 = nextObj as Tuple<object, object>;
            Assert.NotNull(tuple5);
            nextNode = tuple5.Item2 as BehaviorGraphNode;
            Assert.NotNull(nextNode);
            count = graph.PathFinding(nextNode);
            Assert.True(count == 2);

            index = graph.SearchOuterLoopNodeIndex(nextNode);
            Assert.True(index == 2);

            nextObj = graph.SearchNextInnerLoopNode(nextNode);
            tuple5 = nextObj as Tuple<object, object>;
            Assert.NotNull(tuple5);
            nextNode = tuple5.Item2 as BehaviorGraphNode;
            Assert.NotNull(nextNode);
            count = graph.PathFinding(nextNode);
            Assert.True(count == 1);

            index = graph.SearchOuterLoopNodeIndex(nextNode);
            Assert.True(index == 2);

            nextObj = graph.SearchNextInnerLoopNode(nextNode);
            tuple5 = nextObj as Tuple<object, object>;
            Assert.NotNull(tuple5);
            nextNode = tuple5.Item2 as BehaviorGraphNode;
            Assert.NotNull(nextNode);
            count = graph.PathFinding(nextNode);
            Assert.True(count == 0);

            index = graph.SearchOuterLoopNodeIndex(nextNode);
            Assert.True(index == 2);

            var prevNode = graph.SearchPrevInnerLoopNode(nextNode) as BehaviorGraphNode;
            Assert.NotNull(prevNode);
            count = graph.PathFinding(prevNode);
            Assert.True(count == 1);

            var strateties = graph.SearchAllOuterEdgeInfos();
            Assert.True(strateties.Count == 2);
        }
        public void Test_MultiStrategy_1()
        {
            //strategy1: 1->2, 2->3
            var ts1     = new TraceStep(1, 2, "null", "TODO1", "TODO2");
            var ts1Expr = new TraceStepExpr(ts1);
            var ts2     = new TraceStep(2, 3, "null", "TODO2", "TODO3");
            var ts2Expr = new TraceStepExpr(ts2);
            var lst1    = new List <TraceStepExpr>()
            {
                ts1Expr, ts2Expr
            };
            var tuple1 = new Tuple <object, object>("strategy1", lst1);

            //strategy2: 2->3, 3->5, 5->7
            var ts3     = new TraceStep(2, 3, null, "TODO", "TODO1");
            var ts3Expr = new TraceStepExpr(ts3);
            var ts4     = new TraceStep(3, 5, null, "TODO2", "TODO5");
            var ts4Expr = new TraceStepExpr(ts4);
            var ts5     = new TraceStep(5, 7, null, "Test1", "test23");
            var ts5Expr = new TraceStepExpr(ts5);
            var lst2    = new List <TraceStepExpr>()
            {
                ts3Expr, ts4Expr, ts5Expr
            };
            var tuple2 = new Tuple <object, object>("strategy2", lst2);

            var lstStrategy = new List <Tuple <object, object> >();

            lstStrategy.Add(tuple1);
            lstStrategy.Add(tuple2);

            var graph = new BehaviorGraph();

            graph.Insert(lstStrategy);
            Assert.True(graph.Nodes.Count == 3);

            var node1 = graph.Nodes[1];

            Assert.True(node1.OutEdges.Count == 1);
            var node2 = graph.Nodes[2];

            Assert.True(node2.InEdges.Count == 1);
            Assert.True(node2.OutEdges.Count == 0);

            Assert.NotNull(node1.SubGraph);
            Assert.True(node1.SubGraph.Nodes.Count == 3);

            Assert.NotNull(node2.SubGraph);
            Assert.True(node2.SubGraph.Nodes.Count == 4);

            /////////////////////////////////////////////////////
            //Search Test

            var initNode = graph.RetrieveInitInnerNode();

            Assert.NotNull(initNode);
            int count = graph.PathFinding(initNode);

            Assert.True(count == 5);

            var nextObj = graph.SearchNextInnerLoopNode(initNode);
            var tuple5  = nextObj as Tuple <object, object>;

            Assert.NotNull(tuple5);
            var nextNode = tuple5.Item2 as BehaviorGraphNode;

            Assert.NotNull(nextNode);
            count = graph.PathFinding(nextNode);
            Assert.True(count == 4);

            nextObj = graph.SearchNextInnerLoopNode(nextNode);
            tuple5  = nextObj as Tuple <object, object>;
            Assert.NotNull(tuple5);
            nextNode = tuple5.Item2 as BehaviorGraphNode;
            Assert.NotNull(nextNode);
            count = graph.PathFinding(nextNode);
            Assert.True(count == 3);

            var index = graph.SearchOuterLoopNodeIndex(nextNode);

            Assert.True(index == 1);

            nextObj = graph.SearchNextInnerLoopNode(nextNode);
            tuple5  = nextObj as Tuple <object, object>;
            Assert.NotNull(tuple5);
            nextNode = tuple5.Item2 as BehaviorGraphNode;
            Assert.NotNull(nextNode);
            count = graph.PathFinding(nextNode);
            Assert.True(count == 2);

            index = graph.SearchOuterLoopNodeIndex(nextNode);
            Assert.True(index == 2);

            nextObj = graph.SearchNextInnerLoopNode(nextNode);
            tuple5  = nextObj as Tuple <object, object>;
            Assert.NotNull(tuple5);
            nextNode = tuple5.Item2 as BehaviorGraphNode;
            Assert.NotNull(nextNode);
            count = graph.PathFinding(nextNode);
            Assert.True(count == 1);

            index = graph.SearchOuterLoopNodeIndex(nextNode);
            Assert.True(index == 2);

            nextObj = graph.SearchNextInnerLoopNode(nextNode);
            tuple5  = nextObj as Tuple <object, object>;
            Assert.NotNull(tuple5);
            nextNode = tuple5.Item2 as BehaviorGraphNode;
            Assert.NotNull(nextNode);
            count = graph.PathFinding(nextNode);
            Assert.True(count == 0);

            index = graph.SearchOuterLoopNodeIndex(nextNode);
            Assert.True(index == 2);

            var prevNode = graph.SearchPrevInnerLoopNode(nextNode) as BehaviorGraphNode;

            Assert.NotNull(prevNode);
            count = graph.PathFinding(prevNode);
            Assert.True(count == 1);

            var strateties = graph.SearchAllOuterEdgeInfos();

            Assert.True(strateties.Count == 2);
        }