public void TestMethodSortAscending() { // Arrange int[] array = new int[] { 0, 2, 5, 9, 10 }; string[] expected = new string[] { "ZeRo", "two", "FIVE", "NINE", "10" }; BubbleSortCollectionSorter bubbleSortCollectionSorter = new BubbleSortCollectionSorter(); // Act bubbleSortCollectionSorter.SortAscending(array); // Assert Assert.AreEqual(expected, array, "Array not valid"); }
static void Main(string[] args) { ConsoleKeyInfo op; do { Console.Clear(); //Limpiar la pantalla Console.WriteLine("Bobble Sort Method"); Console.ForegroundColor = ConsoleColor.Blue; Console.WriteLine("[A] Sort Ascending"); Console.WriteLine("[B] Sort Descending"); Console.WriteLine("[Esc] Salir"); Console.ForegroundColor = ConsoleColor.White; Console.WriteLine("Select option..."); op = Console.ReadKey(true);//Que no muestre la tecla señalada //métodos son acciones, las propiedades son valores switch (op.Key) { case ConsoleKey.A: var arrayA = RandomArray(); BubbleSortCollectionSorter bubbleSortCollectionSorter = new BubbleSortCollectionSorter(); bubbleSortCollectionSorter.ShowArray(bubbleSortCollectionSorter.SortAscending(arrayA)); break; case ConsoleKey.B: var arrayD = RandomArray(); BubbleSortCollectionSorter bubbleSortCollectionSorterD = new BubbleSortCollectionSorter(); bubbleSortCollectionSorterD.ShowArray(bubbleSortCollectionSorterD.SortDescending(arrayD)); break; case ConsoleKey.Escape: Console.WriteLine("Bye"); break; } } while (op.Key != ConsoleKey.Escape); }