Exemple #1
0
        public void TestEnumerator()
        {
            //arrange
            var arr = new List <int>()
            {
                1, 2, 4
            };

            AlgPlayGroundApp.DataStructures.LinkedList <int> list = new AlgPlayGroundApp.DataStructures.LinkedList <int>();
            foreach (var val in arr)
            {
                list.AddLast(val);
            }

            int index = 0;

            foreach (var entry in list)
            {
                if (index >= arr.Count)
                {
                    throw new IndexOutOfRangeException();
                }

                Assert.AreEqual(arr[index++], entry);
            }
        }
Exemple #2
0
 public void TestRemoveNodeWhenListHasSingleElement()
 {
     //arrange
     AlgPlayGroundApp.DataStructures.LinkedList <int> list = new AlgPlayGroundApp.DataStructures.LinkedList <int>();
     list.AddFirst(5);
     list.Remove(5);
     Assert.IsEmpty(list);
 }
Exemple #3
0
 public void TestRemoveFirrstNodeWhenListHasMultiple()
 {
     //arrange
     AlgPlayGroundApp.DataStructures.LinkedList <int> list = new AlgPlayGroundApp.DataStructures.LinkedList <int>();
     list.AddLast(5);
     list.AddLast(6);
     list.AddLast(7);
     list.Remove(5);
     Assert.AreEqual(new int[] { 6, 7 }, list.ToArray());
 }
Exemple #4
0
 public void TestEmptyEnumerator()
 {
     //arrange
     AlgPlayGroundApp.DataStructures.LinkedList <int> list = new AlgPlayGroundApp.DataStructures.LinkedList <int>();
     Assert.IsEmpty(list);
 }