public void InsertLoopIntoLoopAfter() { //Arrange LinkedLoop <int> list1 = new LinkedLoop <int>(); LinkedLoop <int> list2 = new LinkedLoop <int>(); list1.AddLast(1); list1.AddLast(2); list1.AddLast(3); list2.AddLast(4); list2.AddLast(5); list2.AddLast(6); //Act list1.InsertAfter(list1.last, list2.first, list2.last); //Assert Assert.AreEqual(6, list1.size); Assert.AreEqual(0, list2.size); CheckConsistancy(list1); CheckConsistancy(list2); var items = GetArray(list1); Assert.AreEqual(1, items[0].value); Assert.AreEqual(2, items[1].value); Assert.AreEqual(3, items[2].value); Assert.AreEqual(4, items[3].value); Assert.AreEqual(5, items[4].value); Assert.AreEqual(6, items[5].value); }
public void InsertValueAfter() { //Arrange LinkedLoop <int> list = new LinkedLoop <int>(); list.AddLast(1); list.AddLast(3); //Act list.InsertAfter(list.first, 2); //Assert Assert.AreEqual(3, list.size); CheckConsistancy(list); var n = list.first; for (int i = 0; i < list.size; i++) { Assert.AreEqual(i + 1, n.value); n = n.next; } }