コード例 #1
0
        public void CanCountRightBranchesBreadth()
        {
            // Arrange
            Tree <string> tree = new Tree <string>();

            Node <string> root = new Node <string>("a");
            Node <string> b    = new Node <string>("b");
            Node <string> c    = new Node <string>("c");
            Node <string> d    = new Node <string>("d");
            Node <string> e    = new Node <string>("e");
            Node <string> f    = new Node <string>("f");
            Node <string> g    = new Node <string>("g");

            tree.Root = root;

            root.LeftChild  = b;
            root.RightChild = c;

            b.LeftChild  = d;
            b.RightChild = e;

            c.LeftChild  = f;
            c.RightChild = g;

            // Act
            int result = BreadthFirst.CountRightBranchesBreadth(root);

            // Assert
            Assert.Equal(3, result);
        }