Exemplo n.º 1
0
        public static void ArraySorted([Random(0, 1000, 100, Distinct = true)] int n)
        {
            // Arrange
            var sorter      = new PancakeSorter <int>();
            var intComparer = new IntComparer();

            var(correctArray, testArray) = RandomHelper.GetArrays(n);

            // Act
            sorter.Sort(testArray, intComparer);
            Array.Sort(correctArray, intComparer);

            // Assert
            Assert.AreEqual(testArray, correctArray);
        }
Exemplo n.º 2
0
        public void ArraySorted([Random(0, 1000, 100)] int n)
        {
            // Arrange
            var sorter       = new PancakeSorter <int>();
            var intComparer  = new IntComparer();
            var random       = new Random();
            var testArray    = new int[n];
            var correctArray = new int[n];

            for (var i = 0; i < n; i++)
            {
                var t = random.Next(0, 1000);
                testArray[i]    = t;
                correctArray[i] = t;
            }

            // Act
            sorter.Sort(testArray, intComparer);
            Array.Sort(correctArray, intComparer);

            // Assert
            Assert.AreEqual(testArray, correctArray);
        }
Exemplo n.º 3
0
 public void Setup()
 {
     _pancakeSorter = new PancakeSorter();
 }