Exemplo n.º 1
0
        public void GetMatrices_TwoMatrcesInInput_TwoMatrcesInOutput()
        {
            var factory      = new NoOpOperationFactory();
            var matrixReader = new StreamMatrixReader(factory);
            var inputString  = $"noop{Environment.NewLine}{Environment.NewLine}1{Environment.NewLine}{Environment.NewLine}1{Environment.NewLine}";
            var stringReader = new StringReader(inputString);
            var matrices     = matrixReader.GetMatrices(stringReader);

            Assert.Equal(2, matrices.Count());
        }
Exemplo n.º 2
0
        public void GetMatrices_OneMatrixInInput_OneMatrixInOutput()
        {
            var factory      = new NoOpOperationFactory();
            var matrixReader = new StreamMatrixReader(factory);
            var inputString  = $"noop{Environment.NewLine}{Environment.NewLine}1{Environment.NewLine}";
            var stringReader = new StringReader(inputString);
            var matrices     = matrixReader.GetMatrices(stringReader);

            Assert.Single(matrices);
        }
Exemplo n.º 3
0
        public void GetMatrices_InconsistentAmountOfColumnsInInput_ThrowsInvalidOperationException()
        {
            var factory      = new NoOpOperationFactory();
            var matrixReader = new StreamMatrixReader(factory);
            var inputString  = $"noop{Environment.NewLine}{Environment.NewLine}1{Environment.NewLine}1 2{Environment.NewLine}";
            var stringReader = new StringReader(inputString);

            Assert.Throws <InvalidOperationException>(() =>
            {
                matrixReader.GetMatrices(stringReader).ToList();
            });
        }
Exemplo n.º 4
0
        public void GetMatrices_TwoByTwoMatrixInInput_ProperOutput()
        {
            var factory          = new NoOpOperationFactory();
            var matrixReader     = new StreamMatrixReader(factory);
            var inputString      = $"noop{Environment.NewLine}{Environment.NewLine}1 2{Environment.NewLine}3 4{Environment.NewLine}";
            var stringReader     = new StringReader(inputString);
            var matrices         = matrixReader.GetMatrices(stringReader);
            var expectedMatrices = new Matrix[] { new Matrix(new int[2, 2] {
                    { 1, 2 }, { 3, 4 }
                }) };

            Assert.Equal(expectedMatrices, matrices, new MatrixComparer());
        }