public void CopyToShouldThrowBinaryTreeExceptionDueToIncorrectArrayIndex() { //arrange BinaryTree <int> tree = new BinaryTree <int>(); BinaryTreeException expected = new BinaryTreeException("Index is less then 0."); //act int[] nodes = new int[7]; nodes[0] = 5; nodes[1] = 5; nodes[2] = 5; Action action = () => tree.CopyTo(nodes, -1); BinaryTreeException actual = Assert.Throws <BinaryTreeException>(action); //assert Assert.Contains(expected.Message, actual.Message); }
public void CopyToShouldThrowBinaryTreeExceptionDueToNotEnoughElementInArray() { //arrange BinaryTree <int> tree = new BinaryTree <int>() { 1, 1, 1, 1, 1, 1, 1 }; BinaryTreeException expected = new BinaryTreeException("Not enough elements after index in the destination array."); //act //fix int[] nodes = new int[7]; nodes[0] = 5; nodes[1] = 5; nodes[2] = 5; Action action = () => tree.CopyTo(nodes, 2); BinaryTreeException actual = Assert.Throws <BinaryTreeException>(action); //assert Assert.Contains(expected.Message, actual.Message); }