public void RemovesSpecifiedNode()
 {
     LinkedList<int> list = new LinkedList<int>() { 1, 2, 3 };
     list.RemoveNode(3);
     int[] result = new int[] { 1, 2 };
     Assert.Equal(result, list);
 }
 public void InsertsNodeBeforeSpecifiedNode()
 {
     LinkedList<int> list = new LinkedList<int>() { 1, 2, 3 };
     list.InsertBefore(3, 4);
     int[] result = new int[] { 1, 2, 4, 3 };
     Assert.Equal(result, list);
 }
 public void InsertsNodeAfterSpecifiedNode()
 {
     LinkedList<int> list = new LinkedList<int>() { 1, 2, 3 };
     list.InsertAfter(3, 4);
     int[] result = new int[] { 1, 2, 3, 4 };
     Assert.Equal(result, list);
 }
 public void ClearsTheList()
 {
     LinkedList<int> list = new LinkedList<int>() { 1, 2, 3 };
     Assert.Equal(3, list.Count);
     list.Clear();
     Assert.Equal(0, list.Count);
 }
 public void AddsNodeOnTheFirstPosition()
 {
     LinkedList<int> list = new LinkedList<int>() { 1, 2, 3 };
     Assert.Equal(3, list.Count);
     list.AddFirst(4);
     int[] result = new int[] { 4, 1, 2, 3 };
     Assert.Equal(result, list);
 }
Exemple #6
0
        static void Main(string[] args)
        {
            var list1 = new LinkedList();
            list1.AddLast(2);
            list1.AddLast(4);
            list1.AddLast("6");

            foreach (int i in list1)
            {
                Console.WriteLine(i);
            }
        }
 public void VerifiesEnumeratorFunction()
 {
     LinkedList<int> list = new LinkedList<int>() { 1, 2, 3 };
     Assert.Equal(new int[] { 1, 2, 3 }, list);
 }
 public void ReturnsCounterZero()
 {
     LinkedList<int> list = new LinkedList<int>();
     Assert.Equal(0, list.Count);
 }
 public void ReturnsCountAsThree()
 {
     LinkedList<int> list = new LinkedList<int>() { 1, 2, 3 };
     Assert.Equal(3, list.Count);
 }