public void EventTest()
        {
            int size1   = 3;
            var matrix1 = new SquereMatrix <int>(size1, 1);

            matrix1.ChangeValue += MatrixEventMethods.EventMethods;
            matrix1[1, 1]        = 4;
        }
        public void SumExeptionTest()
        {
            int size1   = 3;
            int size2   = 5;
            var matrix1 = new SquereMatrix <int>(size1, 1);
            var matrix2 = new SquereMatrix <int>(size2, 2);

            Assert.Throws <ArgumentException>(() => SumMatrix(matrix1, matrix2));
            Assert.Throws <ArgumentNullException>(() => SumMatrix(matrix1, null));
        }
        public void IndexExeptionTest(int i, int j)
        {
            int size   = 3;
            var matrix = new SquereMatrix <int>(size, 1);

            Assert.Throws <ArgumentException>(() => matrix[i, j] = 1);
            Assert.Throws <ArgumentException>(() =>
            {
                int p = matrix[i, j];
            });
        }
        public void SumMatrixTest()
        {
            int size    = 3;
            var matrix1 = new SquereMatrix <int>(size, 1);
            var matrix2 = new SquereMatrix <int>(size, 2);

            var result = SumMatrix(matrix1, matrix2);

            var expected = new SquereMatrix <int>(size, 3);

            Assert.IsTrue(result.Equals(expected));
        }
Example #5
0
        static void Main(string[] args)
        {
            int[,] iarray= new int[10,5];
            Random r = new Random(10);
            for (int i = 0; i < 10; i++)
                for (int j = 0; j < 5; j++)
                    iarray[i,j]=r.Next(10);
            Matrix<int> m = new Matrix<int>(10,5,iarray);
            Console.WriteLine(m);
            m.Register();
            m.ChangeSingleCell(4, 2,777);
            Console.WriteLine();

            double[,] darray = new double[3, 3];
            for (int i = 0; i < 3; i++)
                for (int j = 0; j < 3; j++)
                    darray[i, j] =r.Next(10);
            SquereMatrix<double> sqm = new SquereMatrix<double>(3,darray);
            Console.WriteLine(sqm);
            sqm.ChangeSingleCell(2, 2, 77.7);
            Console.WriteLine();

            //конструктор отзеркалит нижнюю половину
            string[,] strarray = new string[3, 3];
            for (int i = 0; i < 3; i++)
                for (int j = 0; j < 3; j++)
                    strarray[i, j] = r.Next(10).ToString();
            SymmetricMatrix<string> smm = new SymmetricMatrix<string>(3, strarray);
            smm.ChangeSingleCell(2, 2, "777");
            Console.WriteLine(smm);

            DateTime[] dtarray = new DateTime[3];
            for (int i = 0; i < 3; i++)
                    dtarray[i] = new DateTime((long)(i+1)*1000000000000000000);
            DiagonalMatrix<DateTime> dm = new DiagonalMatrix<DateTime>(3, dtarray);
            dm.ChangeSingleCell(2, 2, new DateTime((long)7770000000000000));
            Console.WriteLine(dm);

            for (int i = 0; i < 10; i++)
                for (int j = 0; j < 5; j++)
                    iarray[i, j] = r.Next(10);
            Matrix<int> m2 = new Matrix<int>(10, 5, iarray);
            Console.WriteLine(m2);
            Console.WriteLine();
            Console.WriteLine(MatrixExtentor.Addition<int>(m,m2));

            Console.WriteLine();

            Console.Read();
        }
        public void CreateSquereMatrix()
        {
            int size             = 3;
            var valueInt         = 1;
            var valueChar        = 'A';
            var matrixIntSquere  = new SquereMatrix <int>(size, valueInt);
            var matrixCharSquere = new SquereMatrix <char>(size, valueChar);

            for (int i = 0; i < size; i++)
            {
                for (int j = 0; j < size; j++)
                {
                    Assert.That(valueInt, Is.EqualTo(matrixIntSquere[i, j]));
                    Assert.That(valueChar, Is.EqualTo(matrixCharSquere[i, j]));
                }
            }

            var checkInt  = CheckMatrix(matrixIntSquere);
            var checkChar = CheckMatrix(matrixCharSquere);

            Assert.IsTrue(checkInt);
            Assert.IsTrue(checkChar);
        }