public void IsEmptyTest2()
 {
     List myList = new List();
     myList.AddElement(123);
     myList.AddElement(321);
     myList.AddElement(132);
     myList.DeleteElement(123);
     Assert.AreEqual(false, myList.IsEmpty());
 }
Beispiel #2
0
        private static void EventLoop(List list)
        {
            Menu();

            int choice = 1;

            while (choice != 0)
            {
                WriteLine();
                WriteLine("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:
                {
                    WriteLine("Enter the element: ");
                    string str = ReadLine();
                    WriteLine("Enter the position: ");
                    string position = ReadLine();

                    list.Add(str, position);
                    break;
                }

                case 2:
                {
                    WriteLine("Enter the element: ");
                    string str = ReadLine();

                    list.DeleteElement(str);
                    break;
                }

                case 3:
                {
                    WriteLine($"The length of the list: {list.Size()}");
                    break;
                }

                case 4:
                {
                    WriteLine("Enter the number: ");
                    string str = ReadLine();

                    string meaning = list.ReturnString(str);
                    if (meaning == "")
                    {
                        WriteLine("There`s no such element");
                    }
                    else
                    {
                        WriteLine($"The element number {str}: {meaning}");
                    }
                    break;
                }

                case 5:
                {
                    list.Print();
                    break;
                }

                case 6:
                {
                    if (list.IsEmpty())
                    {
                        WriteLine("The list is empty");
                    }
                    else
                    {
                        WriteLine("The list isn`t empty");
                    }
                    break;
                }

                case 7:
                {
                    list.Clean();
                    WriteLine("The list is deleted");
                    break;
                }

                case 0:
                {
                    break;
                }

                default:
                {
                    WriteLine("The wrong number, try again");
                    break;
                }
                }
            }
        }
 public void LastTestTest()
 {
     List myList = new List();
     myList.AddElement(0);
     myList.AddElement(1);
     Assert.AreEqual(true, myList.DeleteElement(0));
     Assert.AreEqual(false, myList.DeleteElement(0));
     myList.AddElement(2);
     myList.AddElement(2);
     Assert.AreEqual(true, myList.DeleteElement(2));
     Assert.AreEqual(true, myList.DeleteElement(2));
     myList.DeleteElement(1);
     Assert.AreEqual(true, myList.IsEmpty());
 }
 public void IsNotEmptyTest()
 {
     List myList = new List();
     myList.AddElement(123);
     Assert.AreEqual(false, myList.IsEmpty());
 }
 public void IsEmptyTest()
 {
     List myList = new List();
     Assert.AreEqual(true, myList.IsEmpty());
 }