public static void ArraySorted([Random(0, 10, 10, Distinct = true)] int n) { // Arrange var sorter = new BogoSorter <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); }
public void ArraySorted([Random(0, 10, 1000)] int n) { // Arrange var sorter = new BogoSorter <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); }