private void NullRootTest(ICommonAncestorFinder commonAncestorFinder) { BinaryTreeNode <int> root = null; BinaryTreeNode <int> node1 = new BinaryTreeNode <int>(9); BinaryTreeNode <int> node2 = new BinaryTreeNode <int>(10); BinaryTreeNode <int> result = commonAncestorFinder.FindCommonAncestor(root, node1, node2); BinaryTreeNode <int> expected = null; Assert.AreEqual(expected, result); }
private void AncestorFoundTest(ICommonAncestorFinder commonAncestorFinder) { BinaryTreeNode <int> root = BuildBinaryTree(); BinaryTreeNode <int> node1 = root.Left.Right; BinaryTreeNode <int> node2 = root.Left.Left.Right; BinaryTreeNode <int> expected = root.Left; BinaryTreeNode <int> result = commonAncestorFinder.FindCommonAncestor(root, node1, node2); Assert.AreEqual(expected, result); }
private void RunTests(ICommonAncestorFinder commonAncestorFinder) { NullRootTest(commonAncestorFinder); NullNodesTest(commonAncestorFinder); AncestorFoundTest(commonAncestorFinder); }