public void AddMultipleObjects()
 {
     LinkedList ll = new LinkedList();
     ll.Add("item1");
     ll.Add("item2");
     ll.Add("item3");
     Assert.IsTrue(ll.Count == 3, "Expected 3 items not " + ll.Count);
     Assert.IsTrue(ll[0].Equals("item1"), "Expected first element to be \"item1\" not " + ll[0]);
     Assert.IsTrue(ll[1].Equals("item2"), "Expected second element to be \"item2\" not " + ll[1]);
 }
 public void ConstructorWithIList()
 {
     ArrayList al = new ArrayList();
     al.Add("al1");
     al.Add("al2");
     al.Add("al3");
     LinkedList ll = new LinkedList(al);
     Assert.IsTrue(ll.Count == 3, "Expected 3 items not " + ll.Count);
     Assert.IsTrue(ll[0].Equals("al1"), "Expected first element to be \"al1\" not " + ll[0]);
     Assert.IsTrue(ll[1].Equals("al2"), "Expected second element to be \"al2\" not " + ll[1]);
 }
        public void Contains()
        {
            LinkedList ll = new LinkedList();
            Assert.IsFalse(ll.Contains("Foo"));

            ll = new LinkedList();
            Assert.IsFalse(ll.Contains(null));
            ll.Add("Foo");
            ll.Add(null);
            ll.Add("Bar");
            Assert.IsTrue(ll.Contains(null));
            Assert.IsTrue(ll.Contains("Bar"));
            Assert.IsTrue(ll.Contains("Foo"));

            ll = new LinkedList();
            ll.Add("Foo");
            ll.Add("Bar");
            Assert.IsFalse(ll.Contains(null));
        }
 public void RemoveObject()
 {
     string item1 = "item1";
     string item2 = "item2";
     string item3 = "item3";
     LinkedList ll = new LinkedList();
     ll.Add(item1);
     ll.Add(item2);
     ll.Add(item3);
     ll.Remove(item2);
     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]);
 }
 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]);
 }
 public void RemoveAtOnEmptyLinkedList()
 {
     LinkedList ll = new LinkedList();
     ll.RemoveAt(0);
 }
 public void IndexOfObject()
 {
     string item1 = "item1";
     string item2 = "item2";
     string item3 = "item3";
     LinkedList ll = new LinkedList();
     ll.Add(item1);
     ll.Add(item2);
     ll.Add(item3);
     int index = ll.IndexOf(item2);
     Assert.IsTrue(index == 1, "Expected index of 1 not " + index);
 }
 public void CopyToWithNegativeIndex()
 {
     LinkedList ll = new LinkedList();
     ll.Add("item1");
     string[] strings = new string[1];
     ll.CopyTo(strings, -1);
 }
 public void Enumerator()
 {
     LinkedList ll = new LinkedList();
     ll.Add("item1");
     ll.Add("item2");
     ll.Add("item3");
     IEnumerator ienum = ll.GetEnumerator();
     Assert.IsTrue(ienum.MoveNext());
     Assert.IsTrue(ienum.Current.Equals("item1"), "Expected first element to be \"item1\" not " + ienum.Current);
     Assert.IsTrue(ienum.MoveNext());
     Assert.IsTrue(ienum.Current.Equals("item2"), "Expected second element to be \"item2\" not " + ienum.Current);
 }
Esempio n. 10
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");
 }
Esempio n. 11
0
 public void CopyToWithZeroIndex()
 {
     LinkedList ll = new LinkedList();
     ll.Add("item1");
     ll.Add("item2");
     ll.Add("item3");
     string[] strings = new string[3];
     ll.CopyTo(strings, 0);
     Assert.IsTrue(strings[0].Equals("item1"), "Expected first element to be \"item1\" not " + strings[0]);
     Assert.IsTrue(strings[1].Equals("item2"), "Expected second element to be \"item2\" not " + strings[1]);
     Assert.IsTrue(strings[2].Equals("item3"), "Expected third element to be \"item3\" not " + strings[2]);
 }
Esempio n. 12
0
 public void CopyToWithNullArray()
 {
     LinkedList ll = new LinkedList();
     ll.Add("item1");
     ll.CopyTo(null, 0);
 }
Esempio n. 13
0
 public void CopyToWithNonZeroIndex()
 {
     LinkedList ll = new LinkedList();
     ll.Add("item1");
     ll.Add("item2");
     ll.Add("item3");
     string[] strings = new string[5];
     strings[0] = "string1";
     strings[1] = "string2";
     ll.CopyTo(strings, 2);
     Assert.IsTrue(strings[0].Equals("string1"), "Expected first element to be \"string1\" not " + strings[0]);
     Assert.IsTrue(strings[1].Equals("string2"), "Expected second element to be \"string2\" not " + strings[1]);
     Assert.IsTrue(strings[2].Equals("item1"), "Expected third element to be \"item1\" not " + strings[2]);
     Assert.IsTrue(strings[3].Equals("item2"), "Expected fourth element to be \"item2\" not " + strings[3]);
     Assert.IsTrue(strings[4].Equals("item3"), "Expected fifth element to be \"item3\" not " + strings[4]);
 }
Esempio n. 14
0
 public void CopyToWithIndexGreaterThanArrayLength()
 {
     LinkedList ll = new LinkedList();
     ll.Add("item1");
     string[] strings = new string[1];
     ll.CopyTo(strings, 2);
 }
Esempio n. 15
0
 public void Insert()
 {
     LinkedList ll = new LinkedList();
     ll.Add("item1");
     ll.Add("item2");
     ll.Insert(1, "item1andahalf");
     Assert.IsTrue(ll.Count == 3, "Expected 3 items not " + ll.Count);
     Assert.IsTrue(ll[0].Equals("item1"), "Expected first element to be \"item1\" not " + ll[0]);
     Assert.IsTrue(ll[1].Equals("item1andahalf"), "Expected second element to be \"item1andahalf\" not " + ll[1]);
     Assert.IsTrue(ll[2].Equals("item2"), "Expected third element to be \"item2\" not " + ll[0]);
 }
Esempio n. 16
0
 public void CopyToWithInsufficientSizeArray()
 {
     LinkedList ll = new LinkedList();
     ll.Add("item1");
     ll.Add("item2");
     string[] strings = new string[2];
     ll.CopyTo(strings, 1);
 }
Esempio n. 17
0
 public LinkedListEnumerator(LinkedList ll)
 {
     _ll = ll;
     _modId = ll._modId;
     _current = _ll._rootNode;
 }