Skip to content

Commit 5bdecfd

Browse files
committed
Fix TestInOrderTraversal
1 parent f0a7599 commit 5bdecfd

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

UnitTest/AlgorithmsTests/BinaryTreeRecursiveWalkerTests.cs

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ private static void TestPreOrderTraversal()
4343
{
4444
if (list[i] != expectedArray[i])
4545
{
46-
throw new InvalidOperationException("Wrong traversal, expected InOrder enumeration of tree!");
46+
throw new InvalidOperationException("Wrong traversal, expected PreOrder enumeration of tree!");
4747
}
4848
}
4949
}
@@ -61,8 +61,15 @@ private static void TestInOrderTraversal()
6161

6262
// Assert the fact that adding items IN-ORDER will result in [10, 5, 3, 7, 15, 13, 17]
6363
BinaryTreeRecursiveWalker.ForEach(Root, addToList, inOrder);
64-
Assert.True(list.ToArray() == new[] { 10, 5, 3, 7, 15, 13, 17 },
65-
"Wrong traversal, expected InOrder enumeration of tree!");
64+
65+
var expectedArray = new[] { 3, 5, 7, 10, 13, 15, 17 };
66+
for (int i = 0; i < list.Count; i++)
67+
{
68+
if (list[i] != expectedArray[i])
69+
{
70+
throw new InvalidOperationException("Wrong traversal, expected InOrder enumeration of tree!");
71+
}
72+
}
6673
}
6774

6875
[Fact]

0 commit comments

Comments
 (0)