public void AddAfterContainsTargetNodeButHeIsLast()
        {
            var list = new ConcurrentLinkedList <int>();

            var node      = list.AddLast(10);
            var addedNode = list.AddAfter(node, 35);

            Assert.Equal(addedNode, list.Last);
        }
        public void AddAfterIsNotContainsTargetNodeThenAddedValueAsNewLastNode()
        {
            var list = new ConcurrentLinkedList <int>();

            list.AddLast(10);
            var newNode = list.AddAfter(new ConcurrentLinkedListNode <int>(), 35);

            Assert.Equal(newNode, list.Last);
        }
Пример #3
0
        public void AddParallelTest()
        {
            var list  = new ConcurrentLinkedList <Guid>();
            var array = Enumerable.Range(0, 1024).Select(_ => Guid.NewGuid()).ToArray();

            Parallel.ForEach(array, () => - 1, (guid, state, index) =>
            {
                if (index == -1)
                {
                    return(list.AddFirst(guid));
                }
                else
                {
                    return(list.AddAfter(index, guid));
                }
            }, i => { });
            list.ToArray().Should().BeEquivalentTo(array);
        }
        public void AddAfterIsNotContainsNodes()
        {
            var list = new ConcurrentLinkedList <int>();

            Assert.Throws <Exception>(() => list.AddAfter(new ConcurrentLinkedListNode <int>(), 10));
        }