private static void ValidateResult(int[,] input, int[,] expectedResult) { var size = input.GetLength(0); var result1 = new int[size, size]; var result2 = new int[size, size]; // Perform deep-copies of the original array for (int i = 0; i < size; i++) { for (int j = 0; j < size; j++) { result1[i, j] = input[i, j]; result2[i, j] = input[i, j]; } } Question1_8.ZeroMatrix(result1); Question1_8.ZeroMatrixNoAdditionalSpace(result2); for (int i = 0; i < size; i++) { for (int j = 0; j < size; j++) { Assert.AreEqual(expectedResult[i, j], result1[i, j]); Assert.AreEqual(expectedResult[i, j], result2[i, j]); } } }
public void InvalidInputsTest() { // Null matrix TestHelpers.AssertExceptionThrown(() => { Question1_8.ZeroMatrix(null); }, typeof(ArgumentNullException)); TestHelpers.AssertExceptionThrown(() => { Question1_8.ZeroMatrixNoAdditionalSpace(null); }, typeof(ArgumentNullException)); }