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

            list.AddLast(10);
            list.AddLast(5);
            list.AddLast(6);
            var node = list.AddLast(11);

            Assert.NotNull(list._root);
            Assert.Null(node.Next);
            Assert.NotNull(list.Last);
            Assert.Equal(11, list.Last.Value);
        }
        public void AddBeforeContainsTargetNode()
        {
            var list = new ConcurrentLinkedList <int>();

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

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

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

            Assert.Equal(newNode, list.First);
        }
        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 AddLastByItemIsNodeResultNodeHasNoOneNodeNext()
        {
            var list = new ConcurrentLinkedList <int>();
            var node = new ConcurrentLinkedListNode <int>()
            {
                Value = 10
            };

            list.AddLast(node);

            Assert.NotNull(list._root);
            Assert.Null(node.Next);
        }
        public Message SendAndWait(Message request)
        {
            String id = Counter().ToString();

            request.SetId(id);

            messageSource.AddLast(request);

            logger.Log("Message " + id + " pushed. Wait for response ...");

            DateTime timeout = DateTime.Now.AddSeconds(10);

            while (DateTime.Now.CompareTo(timeout) < 0)
            {
                Message response = messageResponse.Remove(id);
                if (response != null)
                {
                    return(response);
                }
            }
            logger.Log("SendAndWait timeout on id " + id);
            return(null);
        }