Skip to content

Commit e2f4ebf

Browse files
committed
Fix TestPreOrderTraversal test
1 parent 70a719a commit e2f4ebf

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

UnitTest/AlgorithmsTests/BinaryTreeRecursiveWalkerTests.cs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,14 @@ private static void TestPreOrderTraversal()
3838

3939
// Assert the fact that adding items PRE-ORDER will result in [3, 5, 7, 10, 13, 15, 17]
4040
BinaryTreeRecursiveWalker.ForEach(Root, addToList, preOrder);
41-
Assert.True(list.ToArray() == new[] { 3, 5, 7, 10, 13, 15 },
42-
"Wrong traversal, expected InOrder enumeration of tree!");
41+
var expectedArray = new[] { 10, 5, 3, 7, 15, 13, 17 };
42+
for (int i = 0; i < list.Count; i++)
43+
{
44+
if (list[i] != expectedArray[i])
45+
{
46+
throw new InvalidOperationException("Wrong traversal, expected InOrder enumeration of tree!");
47+
}
48+
}
4349
}
4450

4551
[Fact]

0 commit comments

Comments
 (0)