Example #1
0
        public void TestMethodHashClear()
        {
            Hashtable ht = new Hashtable();
            ht.Init(array);
            ht.Clear();

            Assert.AreEqual(0, ht.Size);
        }
Example #2
0
        public void TestMethodHashGet(int id, string fn, string ln, int age)
        {
            Hashtable ht = new Hashtable();
            ht.Init(array);

            Person act = ht.Get(id);
            Assert.AreEqual(id, act.ID);
            Assert.AreEqual(fn, act.FirstName);
            Assert.AreEqual(ln, act.LastName);
            Assert.AreEqual(age, act.Age);
        }
Example #3
0
        public void TestMethodHashDel()
        {
            Hashtable ht = new Hashtable();
            ht.Init(array);
            var person = new Person("Kent", "Williams", 45);
            ht.Add(person);
            ht.Del(person);

            var actualArr = ht.ToArray();
            Assert.AreEqual(actualArr.Length, ht.Size);
        }
Example #4
0
        public void TestMethodHashAdd()
        {
            Hashtable ht = new Hashtable();
            ht.Init(array);
            var person = new Person ( "Neil", "Shay", 87 );
            ht.Add(person);

            var actualArr = ht.ToArray();
            Assert.AreEqual(person, ht.Get(person.ID));
            Assert.AreEqual(actualArr.Length, ht.Size);
        }
Example #5
0
        static void Main(string[] args)
        {
            #region List
            //AList1 arr0 = new AList1();
            //int[] array = { 10, 1, 2, 5, 8 };

            //  //arr0.Init(array);
            //  //arr0.Output();

            //  //Console.WriteLine("__________________________________");

            //  //Console.WriteLine("Min = " + arr0.Min());
            //  //Console.WriteLine("Min index = " + arr0.MinIndex());
            //  //Console.WriteLine("Max = " + arr0.Max());
            //  //Console.WriteLine("Max index = " + arr0.MaxIndex());
            //  //Console.WriteLine("__________________________________");

            //  // arr0.AddStart(2);
            //  //  arr0.AddEnd(7);
            //  // arr0.AddPos(20, 1);
            //  //arr0.Output();
            //  //Console.WriteLine("__________________________________");

            //  //arr0.DelStart();
            //  // arr0.DelEnd();
            //  //arr0.DelPos(2);
            //  //arr0.Output();
            //  // Console.WriteLine("__________________________________");

            //  //arr0.Reverse();
            //  //arr0.Output();
            //  //Console.WriteLine("__________________________________");
            //  //arr0.HalfReverse();
            //  //arr0.Output();
            //  //Console.WriteLine("__________________________________");

            //  //Console.WriteLine("Index = 2: " + arr0.Get(2));
            //  //Console.WriteLine("__________________________________");
            //  //arr0.Set(-78, 3);
            //  //arr0.Output();
            //  //Console.WriteLine("__________________________________");
            //  //arr0.Sort();
            //  //arr0.Output();
            //  //Console.WriteLine("__________________________________");
            //  //arr0.Clear();
            //  //arr0.Output();
            //  //Console.WriteLine("__________________________________");

            //  LListR list = new LListR();
            //  list.Init(array);
            //  //list.Output();
            //  list.ToArray();
            //  Console.WriteLine("\n__________________________________");

            //  list.AddEnd(30);
            //  list.AddStart(40);
            //  list.AddPos(50, 2);
            //  list.ToArray();
            //  Console.WriteLine("\n__________________________________");

            //  list.DelEnd();
            //  list.DelStart();
            //  list.DelPos(3);
            //  list.ToArray();
            //  Console.WriteLine("\n__________________________________");

            ////  list.Reverse();
            //  Console.WriteLine(" " + list.Get(3));
            //  list.Set(4, 1);
            // // list.HalfReverse();
            ////  list.Sort();
            //  list.ToArray();

            //  Console.WriteLine("Min = " + list.Min());
            //  Console.WriteLine("Min index = " + list.MinIndex());
            //  Console.WriteLine("Max = " + list.Max());
            //  Console.WriteLine("Max index = " + list.MaxIndex());
            //  Console.WriteLine("__________________________________");
            #endregion

            Hashtable ht = new Hashtable();

            Person[] array = new Person[]
                {
                    new Person ("Tom", "Johns", 21),
                    new Person ("Ann", "Bell", 28),
                    new Person ("Ken", "Williams", 45),
                    new Person ("Lila", "Barrow", 37),
                    new Person ("Hugh", "Dough", 12)
                };

            ht.Init(array);
            ht.Add(new Person("Neil", "Shay", 87));
            ht.Del(new Person("Ken", "Williams", 45, 3));
            var arr = ht.ToArray();

            foreach (var a in arr)
            {
                Console.WriteLine(a.FirstName + " " + a.LastName);
            }
            var ar = ht.Get(20);
            Console.WriteLine("___" + ar.FirstName + " " + ar.LastName);

            Console.ReadLine();
        }
Example #6
0
 public void TestMethodHashInit()
 {
     Hashtable ht = new Hashtable();
     ht.Init(array);
     CollectionAssert.AreEqual(array, ht.ToArray());
 }