static void Main() { var list = new DoublyLinkedListExpanded <int>(); list.ForEach(Console.WriteLine); Console.WriteLine("--------------------"); list.AddLast(5); list.AddFirst(3); list.AddFirst(2); list.AddLast(10); Console.WriteLine("Count = {0}", list.Count); list.ForEach(Console.WriteLine); Console.WriteLine("--------------------"); list.RemoveFirst(); list.RemoveLast(); list.RemoveFirst(); list.ForEach(Console.WriteLine); Console.WriteLine("--------------------"); list.RemoveLast(); list.ForEach(Console.WriteLine); Console.WriteLine("--------------------"); Console.WriteLine("2---------2--------2"); list.AddLast(1); list.AddLast(2); list.AddLast(3); list.ForEach(Console.WriteLine); Console.WriteLine("--------------------"); list[0] = 5; list[1] = 6; list[2] = 7; list.AddLast(8); list.AddLast(9); list.AddLast(10); list.ForEach(Console.WriteLine); Console.WriteLine("--------------------"); list.InsertAt(20, 3); list.ForEach(Console.WriteLine); Console.WriteLine("3---------3--------3"); Console.WriteLine(list.RemoveAt(4)); Console.WriteLine("--------------------"); list.ForEach(Console.WriteLine); Console.WriteLine("4---------4--------4"); list.Clear(); Console.WriteLine("--------------------"); list.AddLast(8); list.AddLast(9); list.AddLast(10); }
public void DLLe_ForEach_EmptyList_ShouldEnumerateElementsCorrectly() { // Arrange var list = new DoublyLinkedListExpanded <int>(); // Act var items = new List <int>(); list.ForEach(items.Add); // Assert CollectionAssert.AreEqual(items, new List <int>() { }); }
public void DLLe_AddFirst_EmptyList_ShouldAddElement() { // Arrange var list = new DoublyLinkedListExpanded <int>(); // Act list.AddFirst(5); // Assert Assert.AreEqual(1, list.Count); var items = new List <int>(); list.ForEach(items.Add); CollectionAssert.AreEqual(items, new List <int>() { 5 }); }
public void DLLe_Insert_Element_Inside() { // Arrange var list = new DoublyLinkedListExpanded <int>(); // Act list.AddFirst(0); list.InsertAt(1, 0); list.InsertAt(2, 1); // Assert var items = new List <int>(); list.ForEach(items.Add); CollectionAssert.AreEqual(items, new List <int>() { 1, 2, 0 }); }
public void DLLe_AddFirst_SeveralElements_ShouldAddElementsCorrectly() { // Arrange var list = new DoublyLinkedListExpanded <int>(); // Act list.AddFirst(10); list.AddFirst(5); list.AddFirst(3); // Assert Assert.AreEqual(3, list.Count); var items = new List <int>(); list.ForEach(items.Add); CollectionAssert.AreEqual(items, new List <int>() { 3, 5, 10 }); }
public void DLLe_ForEach_MultipleElements_ShouldEnumerateElementsCorrectly() { // Arrange var list = new DoublyLinkedListExpanded <string>(); list.AddLast("Five"); list.AddLast("Six"); list.AddLast("Seven"); // Act var items = new List <string>(); list.ForEach(items.Add); // Assert CollectionAssert.AreEqual(items, new List <string>() { "Five", "Six", "Seven" }); }
public void DLLe_RemoveLast_OneElement_ShouldMakeListEmpty() { // Arrange var list = new DoublyLinkedListExpanded <int>(); list.AddFirst(5); // Act var element = list.RemoveLast(); // Assert Assert.AreEqual(5, element); Assert.AreEqual(0, list.Count); var items = new List <int>(); list.ForEach(items.Add); CollectionAssert.AreEqual(items, new List <int>() { }); }
public void DLLe_RemoveLast_SeveralElements_ShouldRemoveElementsCorrectly() { // Arrange var list = new DoublyLinkedListExpanded <int>(); list.AddFirst(10); list.AddFirst(9); list.AddFirst(8); // Act var element = list.RemoveLast(); // Assert Assert.AreEqual(10, element); Assert.AreEqual(2, list.Count); var items = new List <int>(); list.ForEach(items.Add); CollectionAssert.AreEqual(items, new List <int>() { 8, 9 }); }