public void AList2SetOneEllTest() { int[] mas = new int[] { 1 }; a.Init(mas); mas = new int[] { 3 }; expectedRes.Init(mas); a.Set(0, 3); CollectionAssert.AreEqual(expectedRes.ToArray(), a.ToArray()); }
private static void ChooseOperation(string operation) { int[] mas; int num = 0; switch (operation) { case "1": Console.WriteLine(list.Size()); break; case "2": list.Clear(); break; case "3": Console.WriteLine("Input array length:"); int n = Convert.ToInt16(Console.ReadLine()); mas = new int[n]; for (int i = 0; i < n; i++) { try { mas[i] = Convert.ToInt16(Console.ReadLine()); } catch { Console.WriteLine("It is not an integer number"); i--; } } list.Init(mas); Console.WriteLine(list.Size()); break; case "4": mas = list.ToArray(); foreach (int a in mas) { Console.WriteLine(a.ToString()); } break; case "5": for (int i = 0; i < 1; i++) { try { num = Convert.ToInt16(Console.ReadLine()); } catch { Console.WriteLine("It is not an integer number"); i--; } } list.AddStart(num); break; case "6": Console.WriteLine("Input number to add:"); for (int i = 0; i < 1; i++) { try { num = Convert.ToInt16(Console.ReadLine()); } catch { Console.WriteLine("It is not an integer number"); i--; } } list.AddEnd(num); break; case "7": Console.WriteLine("Input number to add and the place it will be added to:"); mas = new int[2]; for (int i = 0; i < 2; i++) { try { mas[i] = Convert.ToInt16(Console.ReadLine()); } catch { Console.WriteLine("It is not an integer number"); i--; } } list.AddPos(mas[1], mas[0]); break; case "8": list.DelStart(); break; case "9": list.DelEnd(); break; case "10": Console.WriteLine("Input the index of the number to delete:"); for (int i = 0; i < 1; i++) { try { num = Convert.ToInt16(Console.ReadLine()); } catch { Console.WriteLine("It is not an integer number"); i--; } } list.DelPos(num); break; case "11": Console.WriteLine(list.Min().ToString()); break; case "12": Console.WriteLine(list.Max().ToString()); break; case "13": Console.WriteLine(list.MinI().ToString()); break; case "14": Console.WriteLine(list.MaxI().ToString()); break; case "15": list.Reverse(); break; case "16": list.HalfReverse(); break; case "17": Console.WriteLine("Input the index of the number to get:"); for (int i = 0; i < 1; i++) { try { num = Convert.ToInt16(Console.ReadLine()); } catch { Console.WriteLine("It is not an integer number"); i--; } } Console.WriteLine(list.Get(num).ToString()); break; case "18": Console.WriteLine("Input the index of the number to set and the value:"); mas = new int[2]; for (int i = 0; i < 2; i++) { try { mas[i] = Convert.ToInt16(Console.ReadLine()); } catch { Console.WriteLine("It is not an integer number"); i--; } } list.Set(mas[0], mas[1]); break; case "19": list.Sort(); break; } }