public void IsRandomTest()
        {
            IMatrixGenerator matrixGenerator = new SortedMatrixGenerator(4);
            var firstRandomMatrix            = matrixGenerator.GenerateMatrix();
            var secondRandomMatrix           = matrixGenerator.GenerateMatrix();

            MatrixEmptyCellRandomizator matrixRandomizator = new MatrixEmptyCellRandomizator();

            matrixRandomizator.Randomize(firstRandomMatrix);
            matrixRandomizator.Randomize(secondRandomMatrix);

            MatrixComparer comparer = new MatrixComparer();

            Assert.IsFalse(comparer.AreEqual(firstRandomMatrix, secondRandomMatrix));
        }
Beispiel #2
0
        public bool IsSorted(int[,] matrix)
        {
            if (matrix == null)
            {
                throw new ArgumentNullException("The matrix cannot be null or empty");
            }

            int matrixSize = matrix.GetLength(0);

            IMatrixGenerator matrixGenerator = new SortedMatrixGenerator(matrixSize);

            int[,] sortedMatrix = matrixGenerator.GenerateMatrix();

            for (int i = 0; i < matrixSize; i++)
            {
                for (int j = 0; j < matrixSize; j++)
                {
                    if (matrix[i, j] != sortedMatrix[i, j])
                    {
                        return(false);
                    }
                }
            }

            return(true);
        }
Beispiel #3
0
        public void IsSortedTrueTest()
        {
            IMatrixGenerator   testMatrixGenerator = new SortedMatrixGenerator(4);
            EqualMatrixChecker equalMatrixChecker  = new EqualMatrixChecker();

            int[,] matrix = testMatrixGenerator.GenerateMatrix();
            Assert.IsTrue(equalMatrixChecker.IsSorted(matrix));
        }
        public void RandomizZeroCellTest()
        {
            IMatrixGenerator matrixGenerator = new SortedMatrixGenerator(0);

            int[,] matrix = matrixGenerator.GenerateMatrix();
            MatrixEmptyCellRandomizator matrixRandomizator = new MatrixEmptyCellRandomizator();

            matrixRandomizator.Randomize(matrix);
        }
        public void IsRandomizedEmptyCellTest()
        {
            IMatrixGenerator matrixGenerator = new SortedMatrixGenerator(4);

            int[,] matrix = matrixGenerator.GenerateMatrix();
            MatrixEmptyCellRandomizator matrixRandomizator = new MatrixEmptyCellRandomizator();

            matrixRandomizator.Randomize(matrix);
            MatrixComparer comparer = new MatrixComparer();

            Assert.IsFalse(comparer.IsSorted(matrix));
        }
Beispiel #6
0
        public void IsSortedFalseTest()
        {
            IMatrixGenerator   testMatrixGenerator = new SortedMatrixGenerator(4);
            EqualMatrixChecker equalMatrixChecker  = new EqualMatrixChecker();

            int[,] matrix = testMatrixGenerator.GenerateMatrix();
            int memory = matrix[3, 2];

            matrix[3, 2] = matrix[0, 3];
            matrix[0, 3] = memory;
            Assert.IsFalse(equalMatrixChecker.IsSorted(matrix));
        }