private static void Test_Contain_Returns_True(BSTNode <int> root, int[] values)
        {
            var preOrder  = BinaryTreeRecursiveWalker.TraversalMode.PreOrder;
            var inOrder   = BinaryTreeRecursiveWalker.TraversalMode.InOrder;
            var postOrder = BinaryTreeRecursiveWalker.TraversalMode.PostOrder;

            foreach (var value in values)
            {
                Debug.Assert(
                    true == BinaryTreeRecursiveWalker.Contains(root, value, preOrder),
                    "Wrong boolean returned, expected True from Contains");
            }

            foreach (var value in values)
            {
                Debug.Assert(
                    true == BinaryTreeRecursiveWalker.Contains(root, value, inOrder),
                    "Wrong boolean returned, expected True from Contains");
            }

            foreach (var value in values)
            {
                Debug.Assert(
                    true == BinaryTreeRecursiveWalker.Contains(root, value, postOrder),
                    "Wrong boolean returned, expected True from Contains");
            }
        }
示例#2
0
        private static void TestContainReturnsTrue()
        {
            var values    = new int[] { 10, 5, 3, 7, 15, 13, 17 };
            var preOrder  = BinaryTreeRecursiveWalker.TraversalMode.PreOrder;
            var inOrder   = BinaryTreeRecursiveWalker.TraversalMode.InOrder;
            var postOrder = BinaryTreeRecursiveWalker.TraversalMode.PostOrder;

            foreach (var value in values)
            {
                Assert.True(BinaryTreeRecursiveWalker.Contains(_root, value, preOrder),
                            "Wrong boolean returned, expected True from Contains");
            }

            foreach (var value in values)
            {
                Assert.True(BinaryTreeRecursiveWalker.Contains(_root, value, inOrder),
                            "Wrong boolean returned, expected True from Contains");
            }

            foreach (var value in values)
            {
                Assert.True(BinaryTreeRecursiveWalker.Contains(_root, value, postOrder),
                            "Wrong boolean returned, expected True from Contains");
            }
        }
示例#3
0
        private static void TestContainReturnsFalse()
        {
            var values    = new[] { 0, 20, 30, 40, 50 };
            var preOrder  = BinaryTreeRecursiveWalker.TraversalMode.PreOrder;
            var inOrder   = BinaryTreeRecursiveWalker.TraversalMode.InOrder;
            var postOrder = BinaryTreeRecursiveWalker.TraversalMode.PostOrder;

            foreach (var value in values)
            {
                Assert.False(BinaryTreeRecursiveWalker.Contains(Root, value, preOrder),
                             "Wrong boolean returned, expected False from Contains");
            }

            foreach (var value in values)
            {
                Assert.False(BinaryTreeRecursiveWalker.Contains(Root, value, inOrder),
                             "Wrong boolean returned, expected False from Contains");
            }

            foreach (var value in values)
            {
                Assert.False(BinaryTreeRecursiveWalker.Contains(Root, value, postOrder),
                             "Wrong boolean returned, expected False from Contains");
            }
        }