Beispiel #1
0
 internal static Expected <T> GetExpected <T>(this Singly <T> singly
                                              , T expectedHeadItem
                                              , T expectedTailItem)
 => new Expected <T>
 {
     Count = singly.Count,
     Head  = singly.GetNode(expectedHeadItem),
     Tail  = singly.GetNode(expectedTailItem)
 };
Beispiel #2
0
        public static void SetupLoop <T>(this Singly <T> list, T item)
        {
            var node = list.GetNode(item);

            if (node == null)
            {
                return;
            }
            list.Tail.Next = node;
        }
Beispiel #3
0
        public void LoopStartNode_ReturnsStartNodeOfLoop_WhenLoopExists(
            string strList
            , int startOfLoop)
        {
            var singly       = new Singly <int>(strList.ConvertToInts());
            var expected     = singly.GetExpected();
            var expectedNode = singly.GetNode(startOfLoop);

            singly.SetupLoop(startOfLoop);

            var actualNode = singly.LoopStartNode();

            Assert.Equal(expectedNode, actualNode);
            Assert.True(expectedNode.Item == actualNode.Item);
            AssertHeadTailReferencesAndCount(expected, singly);
        }