Beispiel #1
0
        static void Main(string[] args)
        {
            try
            {
                SuperList <string> sll = new SuperList <string>();
                sll.Add("abc");
                sll.Add("cсссссcc");
                sll = sll + "hi";
                foreach (string st in sll)
                {
                    Console.WriteLine(st);
                }


                Console.WriteLine("Элемент,равный заданному ");
                Console.WriteLine(sll.First(p => p.Equals("abc")));



                Doctor  dr  = new Doctor();
                Patient pat = new Patient();

                dr.say_heal += pat.Heal;
                dr.CommandHeal();
            }
            catch (IndexOutOfRangeException e)
            {
                Console.WriteLine(e.Message);
            }
            Console.ReadKey();
        }
        public void SuperlistCounts()
        {
            SuperList <int> superList = new SuperList <int>();

            superList.Add(1);
            superList.Add(2);
            superList.Add(3);
            int count = 3;

            Assert.AreEqual(superList.Count, count);
        }
        public void SuperlistStoresInitialValue()
        {
            SuperList <int> superint = new SuperList <int>();

            superint.Add(1);
            int test     = superint[0];
            int expected = 1;

            Assert.AreEqual(test, expected);
        }
        public void ClearingListRaisesEvents()
        {
            SuperList <double> testList = new SuperList <double>();

            for (int i = 0; i < 100; i++)
            {
                testList.Add((double)i);
            }

            testList.Clear();
        }
        public void SuperAddCapacity()
        {
            SuperList <int> superList = new SuperList <int>();
            int             test1     = superList.Capacity;

            for (int i = 0; i < 10; i++)
            {
                superList.Add(i);
            }
            int test2 = superList.Capacity;

            Assert.AreNotEqual(test1, test2);
        }
        public void SuperListCopiesDataCorrectly2()
        {
            SuperList <int> superList = new SuperList <int>()
            {
                1, 2, 3
            };

            for (int i = 0; i < 10; i++)
            {
                superList.Add(5);
            }

            Assert.AreEqual(superList[1], 2);
        }
        public void CanGetAddEvent()
        {
            string testItem    = "abc";
            bool   eventCaught = false;

            SuperList <string> testList = new SuperList <string>();

            testList.ItemAdded += (s, e) =>
            {
                eventCaught = true;
                Assert.AreEqual(testItem, e.Item);
                Assert.IsTrue(object.ReferenceEquals(testItem, e.Item));
            };
            testList.Add(testItem);
            Assert.IsTrue(eventCaught);
        }
        public void CanGetRemoveEvent()
        {
            int  testItem    = 1001;
            bool eventCaught = false;

            SuperList <int> testList = new SuperList <int>();

            testList.ItemRemoved += (s, e) =>
            {
                eventCaught = true;
                Assert.AreEqual(testItem, e.Item);
            };
            testList.Add(testItem);
            testList.Remove(testItem);

            Assert.IsTrue(eventCaught);
        }
        public void SuperlistStoresAdditionalValues()
        {
            SuperList <string> superList = new SuperList <string>();

            superList.Add("is");
            superList.Add("this");
            superList.Add("working");
            superList.Add("is");
            superList.Add("this");
            superList.Add("working");
            //I like it, it's staying ugly.
            Assert.IsTrue(superList[0] == superList[3] && superList[1] == superList[4] && superList[2] == superList[5] && superList[0] != superList[1]);
        }
        public void BigSort()
        {
            int             num       = 0;
            Random          random    = new Random();
            SuperList <int> superlist = new SuperList <int>();

            for (int i = 0; i < 100000; i++)
            {
                num = random.Next(1000);
                superlist.Add(num);
            }
            superlist.SortUP();
            num = -1;
            for (int i = 0; i < superlist.Count; i++)
            {
                Assert.IsTrue(num <= superlist[i]);
                num = superlist[i];
            }
        }