Exemplo n.º 1
0
        static void Main(string[] args)
        {
            var provider = new FileMatrixProvider();
            var matrix1  = provider.GetMatrixAsync(@"../../../Matrixes/1.txt");
            var matrix2  = provider.GetMatrixAsync(@"../../../Matrixes/2.txt");

            Task.WaitAll(matrix1, matrix2);

            var manager = new MatrixOperations();
            var result  = manager.Multiply(matrix1.Result, matrix2.Result);

            provider.SaveMatrix(@"../../../Matrixes/3.txt", result);

            Console.WriteLine("Done. Please press any key...");
            Console.ReadLine();
        }
Exemplo n.º 2
0
        public async Task SaveMatrix_ReadAndWriteTheFile_ShouldBeTheSame()
        {
            // Arrange
            FileMatrixProvider provider = new FileMatrixProvider();

            // Act
            var result = await provider.GetMatrixAsync(_path + "1.txt");

            provider.SaveMatrix(_path + "1_result.txt", result);
            var result2 = await provider.GetMatrixAsync(_path + "1_result.txt");

            // Assert
            for (var row = 0; row < result.GetLength(0); row++)
            {
                for (var column = 0; column < result.GetLength(1); column++)
                {
                    Assert.AreEqual(result[row, column], result2[row, column]);
                }
            }
        }