public void SumMatrixTest() { Matrix matrixA = FetchMatrixA(); Matrix matrixB = FetchMatrixB(); Matrix matrixExpected = FetchMatrixAMulB(); ICommand mulCmd = new MatrixSumCommand(matrixA, matrixB); mulCmd.SetResultCallback((isSucced, result) => { Matrix matrixActual = result as Matrix; Assert.AreEqual(matrixExpected.Rows, matrixActual.Rows); Assert.AreEqual(matrixExpected.Columns, matrixActual.Columns); for (int i = 0; i < matrixExpected.Rows; i++) { for (int j = 0; j < matrixExpected.Columns; j++) { Assert.AreEqual(matrixExpected[i, j], matrixActual[i, j], 0.001, "Values computed wrong"); } } }); mulCmd.Run(); }
static void RunApp(string aPath, string bPath, string resultPath) { Matrix matrixA = new MatrixReaderTextFile(aPath).Read(); Matrix matrixB = new MatrixReaderTextFile(bPath).Read(); MatrixSumCommand matrixMult = new MatrixSumCommand(matrixA, matrixB); matrixMult.SetResultCallback((isSuccess, result) => { new MatrixWriterTextFile(resultPath).Write(result as Matrix); }); matrixMult.Run(); }