private static async Task ProcessDirectory(string directory) { if (!Directory.Exists(directory)) { throw new ArgumentException($"Directory {directory} doesn't exist", directory); } var files = Directory .GetFiles(directory) .Select(x => Path.Combine(directory, x)) .ToList(); // Полные пути исходных файлов var operationFactory = new MatrixOperationFactory(Logger); var streamReader = new StreamMatrixReader(operationFactory); var streamWriter = new StreamMatrixWriter(); var progressReporter = new ProgressReporter(files.Count, Logger); await files.ParallelForEachAsync(async file => { using var input = new StreamReader(file); var resultFile = Path.Combine(directory, Path.GetFileNameWithoutExtension(file) + "_result.txt"); // Полный путь до файла с результатом await using var output = new StreamWriter(resultFile); var matrices = streamReader.GetMatrices(input); await streamWriter.WriteMatricesAsync(output, matrices); progressReporter.Report(file); }); }
public void Create_Multiply_MultiplyOperation() { var factory = new MatrixOperationFactory(new NullLogger()); var operation = factory.Create("multiply"); Assert.IsType <MultiplyOperation>(operation); }
public void Create_Transpose_TransposeOperation() { var factory = new MatrixOperationFactory(new NullLogger()); var operation = factory.Create("transpose"); Assert.IsType <TransposeOperation>(operation); }
public void Create_Subtract_SubtractOperation() { var factory = new MatrixOperationFactory(new NullLogger()); var operation = factory.Create("subtract"); Assert.IsType <SubtractOperation>(operation); }
public void Create_Add_AddOperation() { var factory = new MatrixOperationFactory(new NullLogger()); var operation = factory.Create("add"); Assert.IsType <AddOperation>(operation); }
public void Create_InvalidInput_ThrowsInvalidOperationException() { var factory = new MatrixOperationFactory(new NullLogger()); Assert.Throws <InvalidOperationException>(() => factory.Create("testData")); }