예제 #1
0
 public void RemoveAt()
 {
     LinkedList ll = new LinkedList();
     ll.Add("item1");
     ll.Add("item2");
     ll.Add("item3");
     ll.RemoveAt(1);
     Assert.IsTrue(ll.Count == 2, "Expected 2 items not " + ll.Count);
     Assert.IsTrue(ll[0].Equals("item1"), "Expected first element to be \"item1\" not " + ll[0]);
     Assert.IsTrue(ll[1].Equals("item3"), "Expected second element to be \"item3\" not " + ll[1]);
 }
예제 #2
0
 public void RemoveAtOnEmptyLinkedList()
 {
     LinkedList ll = new LinkedList();
     ll.RemoveAt(0);
 }
예제 #3
0
 public void EnumeratorModification()
 {
     LinkedList ll = new LinkedList();
     ll.Add("item1");
     ll.Add("item2");
     ll.Add("item3");
     IEnumerator ienum = ll.GetEnumerator();
     Assert.IsTrue(ienum.MoveNext());
     ll.RemoveAt(0);
     ienum.MoveNext();
     Assert.Fail("Expected enumerator to fail with InvalidOperationException");
 }