Beispiel #1
0
        public void Test1()
        {
            var list = new List <int> {
                8, 5, 1, 2, 5, 4, 7, 5, 2, 1, 2, 1
            };

            CountingSorter.CountingSort(list);
        }
Beispiel #2
0
        public void ShouldCreateSameSizedResult()
        {
            var sorter = new CountingSorter();

            int[] result = sorter.CountingSort(new int[] { 3, 1, 5, 4 }, 5);

            Assert.AreEqual(4, result.Length);
        }
Beispiel #3
0
        public void ShouldSortSingleItem()
        {
            var sorter = new CountingSorter();

            int[] result = sorter.CountingSort(new int[] { 3 }, 5);

            Assert.AreEqual(3, result[0]);
        }
Beispiel #4
0
        public void ShouldNotAllowItemsOutOfRange()
        {
            var sorter = new CountingSorter();

            int[] items = { 3, 1, 5, 4 };

            Assert.Throws <ArgumentOutOfRangeException>(() => sorter.CountingSort(items, 4));
        }
Beispiel #5
0
        public void ShouldSortEmptyArray()
        {
            var sorter = new CountingSorter();

            int[] result = sorter.CountingSort(new int[] { }, 5);

            Assert.IsEmpty(result);
        }
Beispiel #6
0
        public void ShouldSortMultipleItemsWithRepeats()
        {
            var sorter = new CountingSorter();

            int[] result = sorter.CountingSort(new int[] { 4, 3, 4, 5, 1, 1, 5, 4 }, 5);

            int[] expected = { 1, 1, 3, 4, 4, 4, 5, 5 };
            Assert.AreEqual(expected, result);
        }