Beispiel #1
0
        public void BinaryTree_LongestPath_Should_Pass()
        {
            var root   = this.CreateTestTree();
            var t      = new BinaryTree <int>(root);
            var result = t.GetLongestPath();

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

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