public void AddFirst_WhenNoItemsInTheList_ShouldBeTheOnlyElement() { // Arrange var linkedList = new SinglyLinkList<int>(); var node = new SinglyLinkListNode<int>(10); // Act linkedList.AddFirst(node); // Assert Assert.AreEqual(1, linkedList.Count, "There should be only 1 item."); Assert.AreEqual(1, linkedList.Count(), "Enumeration should return single item."); Assert.AreEqual(10, linkedList.First(), "The first item that it returns shall we the expected item."); Assert.IsNotNull(linkedList.GetHeadAndTail().Item1, "Should not be null"); Assert.AreSame(node, linkedList.GetHeadAndTail().Item1, "Head should be referring to the same item."); Assert.AreSame(node, linkedList.GetHeadAndTail().Item2, "Tail should be referring to the same item."); }
public void SinglyLinkedList_WhenInstanceCreated_CountShouldBeZero() { // Arrange var linkedList = new SinglyLinkList<int>(); // Act var count = linkedList.Count; // Assert Assert.AreEqual(0, count, "There should not be any items in the list"); Assert.AreEqual(0, linkedList.Count(), "Should not enumerate any items."); Assert.IsNull(linkedList.GetHeadAndTail().Item1, "Head should be null"); Assert.IsNull(linkedList.GetHeadAndTail().Item2, "Tail should be null"); }