public void DLLe_ToArray_NonEmptyList_ShouldReturnArray() { // Arrange var list = new DoublyLinkedListExpanded <string>(); list.AddLast("Five"); list.AddLast("Six"); list.AddLast("Seven"); // Act var arr = list.ToArray(); // Assert CollectionAssert.AreEqual(arr, new string[] { "Five", "Six", "Seven" }); }
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_AddLast_SeveralElements_ShouldAddElementsCorrectly() { // Arrange var list = new DoublyLinkedListExpanded <int>(); // Act list.AddLast(5); list.AddLast(10); list.AddLast(15); // Assert Assert.AreEqual(3, list.Count); var items = new List <int>(); list.ForEach(items.Add); CollectionAssert.AreEqual(items, new List <int>() { 5, 10, 15 }); }
public void DLLe_IEnumerable_NonGeneric_MultipleElements() { // Arrange var list = new DoublyLinkedListExpanded <object>(); list.AddLast("Five"); list.AddLast(6); list.AddLast(7.77); // Act var enumerator = ((IEnumerable)list).GetEnumerator(); var items = new List <object>(); while (enumerator.MoveNext()) { items.Add(enumerator.Current); } // Assert CollectionAssert.AreEqual(items, new List <object>() { "Five", 6, 7.77 }); }
public void DLLe_IEnumerable_Foreach_MultipleElements() { // Arrange var list = new DoublyLinkedListExpanded <string>(); list.AddLast("Five"); list.AddLast("Six"); list.AddLast("Seven"); // Act var items = new List <string>(); foreach (var element in list) { items.Add(element); } // Assert CollectionAssert.AreEqual(items, new List <string>() { "Five", "Six", "Seven" }); }
public void DLLe_RemoveFirst_SeveralElements_ShouldRemoveElementsCorrectly() { // Arrange var list = new DoublyLinkedListExpanded <int>(); list.AddLast(5); list.AddLast(6); list.AddLast(7); // Act var element = list.RemoveFirst(); // Assert Assert.AreEqual(5, element); Assert.AreEqual(2, list.Count); var items = new List <int>(); list.ForEach(items.Add); CollectionAssert.AreEqual(items, new List <int>() { 6, 7 }); }
public void DLLe_ForEach_SingleElement_ShouldEnumerateElementsCorrectly() { // Arrange var list = new DoublyLinkedListExpanded <int>(); list.AddLast(5); // Act var items = new List <int>(); list.ForEach(items.Add); // Assert CollectionAssert.AreEqual(items, new List <int>() { 5 }); }
public void DLLe_AddLast_EmptyList_ShouldAddElement() { // Arrange var list = new DoublyLinkedListExpanded <int>(); // Act list.AddLast(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_RemoveFirst_OneElement_ShouldMakeListEmpty() { // Arrange var list = new DoublyLinkedListExpanded <int>(); list.AddLast(5); // Act var element = list.RemoveFirst(); // 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>() { }); }