Esempio n. 1
0
        public void BinaryTree_FindPath_NotExist()
        {
            var root   = this.CreateTestTree();
            var t      = new BinaryTree <int>(root);
            var result = t.FindPath(root, 8);

            result.Should().BeNull("result should be null.");
        }
Esempio n. 2
0
        public void BinaryTree_FindPath_InnerNode()
        {
            var root   = this.CreateTestTree();
            var t      = new BinaryTree <int>(root);
            var result = t.FindPath(root, 5);

            result.Should().NotBeNull("result should not be null.");
            result.Count.Should().Be(3, "Incorrect number of items in the longest path.");
            List <int> expected = new List <int> {
                1, 2, 5
            };

            for (int i = 0; i < 3; i++)
            {
                result[i].Should().Be(expected[i], "Incorrect result at position {0}", i);
            }
        }