コード例 #1
0
            public void GetPreOrden_RootNodeHasNoChildren_ReturnsRootValue()
            {
                var tree = new MyNode(1);
                var recorridoEnProfundidad = new RecorridoEnProfundidad();

                var result = recorridoEnProfundidad.GetPreOrdenRec(tree);

                Assert.AreEqual <string>("1", result);
            }
コード例 #2
0
            public void GetPreOrden_RootNodeIsNull_ReturnsNull()
            {
                var tree = (MyNode)null;
                var recorridoEnProfundidad = new RecorridoEnProfundidad();

                var result = recorridoEnProfundidad.GetPreOrdenRec(tree);

                Assert.AreEqual <string>(null, result);
            }
コード例 #3
0
            public void GetPreOrden_RootNodeHasManyChildren_ReturnsRootValue()
            {
                var tree = new MyNode(2);

                tree.Left = new MyNode(7);
                //
                tree.Left.Left  = new MyNode(2);
                tree.Left.Right = new MyNode(6);
                //
                tree.Left.Right.Left  = new MyNode(5);
                tree.Left.Right.Right = new MyNode(11);

                tree.Right = new MyNode(5);
                //
                tree.Right.Right = new MyNode(9);
                //
                tree.Right.Right.Left = new MyNode(4);
                var recorridoEnProfundidad = new RecorridoEnProfundidad();

                var result = recorridoEnProfundidad.GetPreOrdenRec(tree);

                Assert.AreEqual <string>("2((7)((2) (6)((5) (11))) (5)( (9)((4) )))", result);
            }