Пример #1
0
        public void Test_Traverse_RootNode_Has_No_Children_RootNode_Visited()
        {
            var rootNode = new MockNode();

            _tree.RootNode = rootNode;

            var traverser = new PostorderTraversalStrategy();

            traverser.Traverse <object>(_tree, _visitor);

            Assert.IsTrue(rootNode.WasVisisted);
            Assert.IsTrue(_visitor.NodesVisited.Count == 1);
        }
Пример #2
0
        public void Test_Traverse_RootNode_Has_Children_Tree_Visited_In_Preorder_Order()
        {
            //Postorder pattern is 10, 5, 6, 2, 7, 8, 3, 9, 4, 1

            var expected = new List <int> {
                10, 5, 6, 2, 7, 8, 3, 9, 4, 1
            };

            BuildTreeForTest();

            var traverser = new PostorderTraversalStrategy();

            traverser.Traverse <object>(_tree, _visitor);

            Assert.IsTrue(_visitor.NodesVisited.SequenceEqual(expected));
        }