コード例 #1
0
        public void Remove_RemoveExistNodeWithNullValueFromListWithOneNode_TrueReturned()
        {
            // Arrange
            NodeWithLink <EquatableMock>       node0 = new NodeWithLink <EquatableMock>(null);
            LoopSingleLinkList <EquatableMock> list  = new LoopSingleLinkList <EquatableMock>(node0);
            EquatableMock removeValue = null;
            // Act
            bool isDeleted = list.Remove(removeValue);

            // Assert
            Assert.True(isDeleted);
            Assert.Null(list.First);
            Assert.Null(list.Last);
        }
コード例 #2
0
        public void Contains_ContainsExistNodeWithNullValue_TrueReturned()
        {
            // Arrange
            NodeWithLink <EquatableMock>[] sequence = CreateSequenceOfFiveNodes();
            EquatableMock existValue = null;
            LoopSingleLinkList <EquatableMock> list = new LoopSingleLinkList <EquatableMock>(sequence);

            list.AddLast(existValue);
            // Act
            bool isFound = list.Contains(existValue);

            // Assert
            Assert.True(isFound);
        }
コード例 #3
0
        public void Find_FindExistNodeWithNullValue_NotNullNodeReturned()
        {
            // Arrange
            NodeWithLink <EquatableMock>[] sequence = CreateSequenceOfFiveNodes();
            EquatableMock existValue = null;
            LoopSingleLinkList <EquatableMock> list = new LoopSingleLinkList <EquatableMock>(sequence);

            list.AddLast(existValue);
            // Act
            NodeWithLink <EquatableMock> found = list.Find(existValue);

            // Assert
            Assert.NotNull(found);
        }
コード例 #4
0
        public void Remove_RemoveExistMiddleNodeWithNullValueFromList_TrueReturned()
        {
            // Arrange
            NodeWithLink <EquatableMock>[] sequence = CreateSequenceOfFiveNodes();
            NodeWithLink <EquatableMock>   node1    = sequence[0];
            NodeWithLink <EquatableMock>   node3    = sequence[2];
            NodeWithLink <EquatableMock>   node2    = new NodeWithLink <EquatableMock>(null);

            sequence[1] = node2;
            LoopSingleLinkList <EquatableMock> list = new LoopSingleLinkList <EquatableMock>(sequence);
            EquatableMock removeValue = node2.Value;
            // Act
            bool isDeleted = list.Remove(removeValue);

            // Assert
            Assert.True(isDeleted);
            Assert.Same(node3, node1?.Next);
        }