Exemplo n.º 1
0
        public void IsPalindrome_ReturnsTrue_WhenListIsPalindrome(
            string strList)
        {
            var singly   = new Singly <int>(strList.ConvertToInts());
            var expected = singly.GetExpected();

            var actual = singly.IsPalindrome();

            Assert.True(actual);
            AssertHeadTailReferencesAndCount(expected, singly);
        }
Exemplo n.º 2
0
        public void LoopStartNode_ReturnsNull_WhenLoopDoesNotExists(
            string strList)
        {
            var singly   = new Singly <int>(strList.ConvertToInts());
            var expected = singly.GetExpected();

            var actualNode = singly.LoopStartNode();

            Assert.Null(actualNode);
            AssertHeadTailReferencesAndCount(expected, singly);
        }
Exemplo n.º 3
0
        public void MiddleNode_ReturnsTheMiddleNode_WhenListIsNotEmpty(
            string actualStr
            , int expectedItem)
        {
            var singly   = new Singly <int>(actualStr.ConvertToInts());
            var expected = singly.GetExpected();

            var actual = singly.MiddleNode();

            Assert.True(expectedItem == actual.Item);
            AssertHeadTailReferencesAndCount(expected, singly);
        }
Exemplo n.º 4
0
        public void LoopLength_ReturnsLengthOfLoop_WhenLoopExistsInTheList(
            string strList
            , int startOfLoop
            , int expectedLoopLength)
        {
            var singly   = new Singly <int>(strList.ConvertToInts());
            var expected = singly.GetExpected();

            singly.SetupLoop(startOfLoop);

            var actualLoopLength = singly.LoopLength();

            Assert.True(expectedLoopLength == actualLoopLength);
            AssertHeadTailReferencesAndCount(expected, singly);
        }
Exemplo n.º 5
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);
        }