public void Add3ElementsCheckPresenceAndReturnTheSecondShallReturnTrue333() { list.Add("111", 1); list.Add("222", 2); list.Add("333", 2); Assert.IsTrue(list.CheckPresence("333")); Assert.AreEqual("333", list.GetValueByPosition(2)); }
private static void EventLoop(UniqueList list) { Menu(); int choice = 1; while (choice != 0) { WriteLine(); Write("Enter your choice: "); string input = ReadLine(); while (!int.TryParse(input, out choice)) { WriteLine("It`s not a number, try again: "); input = ReadLine(); } switch (choice) { case 1: { Write("Enter the element: "); string str = ReadLine(); Write("Enter the position: "); int position = int.Parse(ReadLine()); try { list.Add(str, position); } catch (NotUniqueElementException e) { WriteLine(e.Message); } catch (WrongPositionException e) { WriteLine(e.Message); } break; } case 2: { Write("Enter the element: "); string str = ReadLine(); try { list.DeleteElement(str); } catch (CannotDeleteNotExistedElementException e) { WriteLine(e.Message); } break; } case 3: { WriteLine($"The length of the list: {list.GetSize()}"); break; } case 4: { Write("Enter the number: "); int number = int.Parse(ReadLine()); string meaning = list.GetValueByPosition(number); if (meaning == "") { WriteLine("There`s no such element"); } else { WriteLine($"The element number {number}: {meaning}"); } break; } case 5: { Write("The list: "); list.PrintList(); break; } case 6: { if (list.IsEmpty()) { WriteLine("The list is empty"); } else { WriteLine("The list isn`t empty"); } break; } case 0: { break; } default: { WriteLine("The wrong number, try again"); break; } } } }