public void BubbleSort_EmptyArr_Test() { // arrange int[,] result = { }; // act SumSort ss = new SumSort(true); Sorter sorter = new Sorter(ss); sorter.ChangeSortType(new MaxSort(true)); // assert Assert.ThrowsException <ArgumentOutOfRangeException>(() => sorter.Sort(result)); }
public void BubbleSort_NullArr_Test() { // arrange int[,] result = null; // act SumSort ss = new SumSort(true); Sorter sorter = new Sorter(ss); sorter.ChangeSortType(new MaxSort(true)); result = sorter.Sort(result); // assert Assert.ThrowsException <NullReferenceException>(() => sorter.Sort(result)); }
public void BubbleSort_AscMax_Test() { // arrange int[,] result = { { 1, 2, 3 }, { 4, 5, 6 }, { 7, 8, 9 } }; int[,] expectedarray = { { 1, 2, 3 }, { 4, 5, 6 }, { 7, 8, 9 } }; // act SumSort ss = new SumSort(true); Sorter sorter = new Sorter(ss); sorter.ChangeSortType(new MaxSort(true)); result = sorter.Sort(result); // assert Assert.IsTrue(AreEqualse(expectedarray, result)); }
static void Main(string[] args) { //1 double eps = 0; double dx = 9; int x0 = 2; Newton newton = new Newton(eps); Console.WriteLine("Результат: " + newton.Exec(x0, dx)); //Task2 int[,] array = { { 26, 22, 14 }, { 23, 5, 13 }, { 44, 8, 11 } }; Console.WriteLine("Input array"); BubbleSortTask.Display(array); SumSort ss = new SumSort(true); Sorter sorter = new Sorter(ss); Console.WriteLine("\r\nIn order of decreasing sums of elements of rows of the matrix"); sorter.ChangeSortType(new SumSort(false)); array = sorter.Sort(array); BubbleSortTask.Display(array); Console.WriteLine("\r\nIn order of increasing sums of elements of rows of the matrix"); sorter.ChangeSortType(new SumSort(true)); array = sorter.Sort(array); BubbleSortTask.Display(array); Console.WriteLine("\r\nIn order of decreasing max element of rows of the matrix"); sorter.ChangeSortType(new MaxSort(false)); array = sorter.Sort(array); BubbleSortTask.Display(array); Console.WriteLine("\r\nIn order of increasing max element of rows of the matrix"); sorter.ChangeSortType(new MaxSort(true)); array = sorter.Sort(array); BubbleSortTask.Display(array); Console.WriteLine("\r\nIn order of decreasing min element of rows of the matrix"); sorter.ChangeSortType(new MinSort(false)); array = sorter.Sort(array); BubbleSortTask.Display(array); Console.WriteLine("\r\nIn order of increasing min element of rows of the matrix"); sorter.ChangeSortType(new MinSort(true)); array = sorter.Sort(array); BubbleSortTask.Display(array); Console.ReadKey(); }