public void GetKnotNode_ReturnsNull_IfTheListIsNotKnotted_3() { var head = LinkedListNode <int> .Create(new[] { 1, 2, 3 }); Debug.Assert(head != null); Assert.IsNull(head.GetKnotNode()); }
public void Create_ReturnsOneValidNode_ForSequenceOfOne() { var head = LinkedListNode <int> .Create(new[] { 1 }); Assert.NotNull(head); Assert.AreEqual(1, head.Value); Assert.IsNull(head.Next); }
public void GetIntersectionNode_ReturnsFirstNode_IfSelfChecking_1() { var head = LinkedListNode <int> .Create(new[] { 1 }); Debug.Assert(head != null); Assert.AreSame(head, head.GetIntersectionNode(head)); }
public void GetKnotNode_ReturnsHead_IfKnot() { var head = LinkedListNode <int> .Create(new[] { 1 }); Debug.Assert(head != null); head.Next = head; Assert.AreSame(head, head.GetKnotNode()); }
public void GetIntersectionNode_ReturnsMiddleNode_IfSelfChecking_ByMiddle() { var head = LinkedListNode <int> .Create(new[] { 1, 2, 3 }); Debug.Assert(head != null); Debug.Assert(head.Next != null); Assert.AreSame(head.Next, head.GetIntersectionNode(head.Next)); }
public void Enumeration_ReturnsSelf() { var node = LinkedListNode <char> .Create("A"); Debug.Assert(node != null); TestHelper.AssertSequence(node, node); }
public void Create_ReturnsTwoValidNodes_ForSequenceOfTwo() { var head = LinkedListNode <int> .Create(new[] { 1, 2 }); Assert.NotNull(head); Assert.AreEqual(1, head.Value); Assert.IsNotNull(head.Next); Assert.AreEqual(2, head.Next.Value); }
public void GetLength_ReturnsOne_ForSingleNodeList() { var head = LinkedListNode <int> .Create(new[] { 1 }); Debug.Assert(head != null); var result = head.GetLength(); Assert.AreEqual(1, result); }
public void GetLength_ReturnsTwo_ForTwoNodeList() { var head = LinkedListNode <int> .Create(new[] { 1, 2 }); Debug.Assert(head != null); var result = head.GetLength(); Assert.AreEqual(2, result); }
public void GetTailNode_ReturnsFirstNode_ForSingleNodeList() { var head = LinkedListNode <int> .Create(new[] { 1 }); Debug.Assert(head != null); var tail = head.GetTailNode(); Assert.AreSame(head, tail); }
public void TryGetMiddleAndTailNodes_ReturnsTwo_ForTwoNodeList() { var head = LinkedListNode <int> .Create(new[] { 1, 2 }); Debug.Assert(head != null); var result = head.TryGetMiddleAndTailNodes(out _, out _); Assert.AreEqual(2, result); }
public void GetTailNode_ReturnsSecondNode_ForTwoNodeList() { var head = LinkedListNode <int> .Create(new[] { 1, 2 }); Debug.Assert(head != null); var tail = head.GetTailNode(); Assert.AreSame(head.Next, tail); }
public void TryGetMiddleAndTailNodes_ReturnsSecondNode_AsTail_ForTwoNodeList() { var head = LinkedListNode <int> .Create(new[] { 1, 2 }); Debug.Assert(head != null); head.TryGetMiddleAndTailNodes(out _, out var tail); Assert.AreSame(head.Next, tail); }
public void TryGetMiddleAndTailNodes_ReturnsSecondNode_AsMiddle_ForThreeNodeList() { var head = LinkedListNode <int> .Create(new[] { 1, 2, 3 }); Debug.Assert(head != null); head.TryGetMiddleAndTailNodes(out var middle, out _); Assert.AreSame(head.Next, middle); }
public void TryGetMiddleAndTailNodes_ReturnsFirstNode_AsTail_ForSingleNodeList() { var head = LinkedListNode <int> .Create(new[] { 1 }); Debug.Assert(head != null); head.TryGetMiddleAndTailNodes(out _, out var tail); Assert.AreSame(head, tail); }
public void GetMiddleNode_ReturnsSecondNode_ForThreeNodeList() { var head = LinkedListNode <int> .Create(new[] { 1, 2, 3 }); Debug.Assert(head != null); var result = head.GetMiddleNode(); Assert.AreSame(head.Next, result); }
public void GetMiddleNode_ReturnsFirstNode_ForTwoNodeList() { var head = LinkedListNode <int> .Create(new[] { 1, 2 }); Debug.Assert(head != null); var result = head.GetMiddleNode(); Assert.AreSame(head, result); }
public void Reverse_DoesNothing_ForSingleNode() { var head = LinkedListNode <int> .Create(new[] { 1 }); Debug.Assert(head != null); var newHead = head.Reverse(); Assert.AreSame(head, newHead); Assert.IsNull(newHead.Next); }
public void GetKnotNode_ReturnsSecond_IfKnot() { var head = LinkedListNode <int> .Create(new[] { 1, 2 }); Debug.Assert(head != null); Debug.Assert(head.Next != null); head.Next.Next = head; Assert.That(head.Next == head.GetKnotNode()); }
public void TryGetMiddleAndTailNodes_ReturnsMinusOne_ForSingleKnottedNode() { var head = LinkedListNode <int> .Create(new[] { 1 }); Debug.Assert(head != null); head.Next = head; var len = head.TryGetMiddleAndTailNodes(out _, out _); Assert.AreEqual(-1, len); }
public void GetIntersectionNode_ReturnsTheProperNode_3() { var list1 = LinkedListNode <int> .Create(new[] { 1, 2, 3, 4, 5 }); Debug.Assert(list1 != null); var list2 = LinkedListNode <int> .Create(new[] { 6 }); Debug.Assert(list2 != null); list2.Next = list1.GetTailNode(); Assert.IsTrue(list1.GetIntersectionNode(list2) == list2.Next); }
public void Enumeration_ReturnsSequence() { var head = LinkedListNode <char> .Create("ALEX"); Debug.Assert(head != null); Debug.Assert(head.Next != null); Debug.Assert(head.Next.Next != null); TestHelper.AssertSequence(head, head, head.Next, head.Next.Next, head.Next.Next.Next); }
public void GetIntersectionNode_ReturnsTheProperNode_1() { var list1 = LinkedListNode <int> .Create(new[] { 1, 2, 3, 4, 5 }); Debug.Assert(list1 != null); var list2 = LinkedListNode <int> .Create(new[] { 12 }); Debug.Assert(list2 != null); list2.Next = list1.Next; Assert.AreSame(list1.Next, list2.GetIntersectionNode(list1)); }
public void GetIntersectionNode_ReturnsTheProperNode_2() { var list1 = LinkedListNode <int> .Create(new[] { 1, 2, 3, 4, 5 }); Debug.Assert(list1 != null); var list2 = LinkedListNode <int> .Create(new[] { 11, 12, 13, 14, 15, 16 }); Debug.Assert(list2 != null); list2.GetTailNode().Next = list1.GetMiddleNode(); Assert.AreSame(list1.GetMiddleNode(), list2.GetIntersectionNode(list1)); }
public void Reverse_Reverses_AListOfTwo() { var e1 = LinkedListNode <int> .Create(new[] { 1, 2 }); Debug.Assert(e1 != null); var e2 = e1.Next; Debug.Assert(e2 != null); var newHead = e1.Reverse(); Assert.AreSame(e2, newHead); Assert.AreSame(e2.Next, e1); Assert.IsNull(e1.Next); }
public void Create_ReturnsNull_ForEmptySequence() { var head = LinkedListNode <int> .Create(new int[] { }); Assert.IsNull(head); }