public void SortInputMatrixBySmallestElementAscending()
        {
            int[,] inputMatrix = { { 75, 19, 45 }, { 49, 52, 78 }, { 81, 6, 40 } };
            int[,] actual      = inputMatrix;
            int row        = 3;
            int column     = 3;
            var descending = false;

            int[] indexes = MatrixHelper.MatrixIndexes(inputMatrix, row, column);
            MatrixSortByMinElement sortBySumAsc = new MatrixSortByMinElement(inputMatrix, row, column, indexes);
            var chooseSortingStrategy           = new SortingStrategy(((IMatrixSort)sortBySumAsc).SortMatrix);

            actual          = chooseSortingStrategy.Invoke(descending);
            int[,] expected = { { 6, 40, 81 }, { 19, 45, 75 }, { 49, 52, 78 } };
            CollectionAssert.AreEqual(expected, actual, "{0} != {1}", expected, actual);
        }
Esempio n. 2
0
        public void Sort()
        {
            PhotoWrapper temp;

            for (int x = 0; x < m_Photos.Count; x++)
            {
                for (int y = 0; y < m_Photos.Count - 1; y++)

                {
                    if (SortingStrategy.Invoke(m_Photos[y], m_Photos[y + 1]))
                    {
                        temp            = m_Photos[y];
                        m_Photos[y]     = m_Photos[y + 1];
                        m_Photos[y + 1] = temp;
                    }
                }
            }
        }