public void AddMultipleElementsWithRepetitions() { var list = new SinglyLinkedLinkedList<int>(); list.Add(4); list.Add(58); list.Add(659816519); list.Add(165965); list.Add(659816519); list.Add(165965); Assert.AreEqual(6, list.Count, MESSAGE_COUNTNOTMATCHING); Assert.AreEqual(2, list.FirstIndexOf(659816519), MESSAGE_FIRSTINDEXOF); Assert.AreEqual(0, list.FirstIndexOf(4), MESSAGE_FIRSTINDEXOF + " Item at index 0."); Assert.AreEqual(4, list.LastIndexOf(659816519), MESSAGE_LASTINDEXOF); Assert.AreEqual(5, list.LastIndexOf(165965), MESSAGE_LASTINDEXOF + " Item at last index."); }
public void AddSingleElementIntoEmptyCollection() { var list = new SinglyLinkedLinkedList<int>(); list.Add(3); Assert.AreEqual(1, list.Count, MESSAGE_COUNTNOTMATCHING); Assert.AreEqual(0, list.FirstIndexOf(3), MESSAGE_FIRSTINDEXOF); Assert.AreEqual(0, list.LastIndexOf(3), MESSAGE_LASTINDEXOF); }
public void RemoveElementAtIndexZero() { var list = new SinglyLinkedLinkedList<int>(); list.Add(4); list.Add(58); list.Add(659816519); list.Add(165965); list.Remove(0); Assert.AreEqual(3, list.Count, MESSAGE_COUNTNOTMATCHING); Assert.AreEqual(-1, list.FirstIndexOf(4), MESSAGE_FIRSTINDEXOF); Assert.AreEqual(2, list.FirstIndexOf(165965), MESSAGE_FIRSTINDEXOF); Assert.AreEqual(-1, list.LastIndexOf(4), MESSAGE_LASTINDEXOF); var expectedList = this.FillIntoList(list); CollectionAssert.AreEqual(expectedList, new List<int>() { 58, 659816519, 165965 }, "Elements' order is not correct."); }
public void RemoveRepetitiveElementFromListWithRepetitions() { var list = new SinglyLinkedLinkedList<int>(); list.Add(4); list.Add(58); list.Add(659816519); list.Add(165965); list.Add(659816519); list.Add(165965); list.Remove(2); Assert.AreEqual(5, list.Count, MESSAGE_COUNTNOTMATCHING); Assert.AreEqual(1, list.FirstIndexOf(58), MESSAGE_FIRSTINDEXOF); Assert.AreEqual(1, list.LastIndexOf(58), MESSAGE_LASTINDEXOF); Assert.AreEqual(3, list.FirstIndexOf(659816519), MESSAGE_FIRSTINDEXOF); Assert.AreEqual(3, list.LastIndexOf(659816519), MESSAGE_LASTINDEXOF); var expectedList = this.FillIntoList(list); CollectionAssert.AreEqual(expectedList, new List<int>() { 4, 58, 165965, 659816519, 165965 }, "Elements' order is not correct."); }