public void enqueue_dequeue_then_wait_on_dequeue()
        {
            var queue = new BlockingConcurrentQueue<int>();
            var cts = new CancellationTokenSource(TimeSpan.FromMilliseconds(30));

            queue.Enqueue(1);
            queue.Dequeue(cts.Token);
            Assert.Throws<OperationCanceledException>(() => queue.Dequeue(cts.Token));
        }
        public void enqueue_dequeue_then_wait_on_dequeue()
        {
            var queue = new BlockingConcurrentQueue <int>();
            var cts   = new CancellationTokenSource(TimeSpan.FromMilliseconds(30));

            queue.Enqueue(1);
            queue.Dequeue(cts.Token);
            Assert.Throws <OperationCanceledException>(() => queue.Dequeue(cts.Token));
        }
        public void enqueue_enqueue_does_not_wait_on_both_dequeue()
        {
            var queue = new BlockingConcurrentQueue <int>();
            var cts   = new CancellationTokenSource(TimeSpan.FromMilliseconds(30));

            queue.Enqueue(1);
            queue.Enqueue(2);

            Assert.AreEqual(1, queue.Dequeue(cts.Token));
            Assert.AreEqual(2, queue.Dequeue(cts.Token));
        }
        public void enqueue_enqueue_does_not_wait_on_both_dequeue()
        {
            var queue = new BlockingConcurrentQueue<int>();
            var cts = new CancellationTokenSource(TimeSpan.FromMilliseconds(30));

            queue.Enqueue(1);
            queue.Enqueue(2);

            Assert.AreEqual(1, queue.Dequeue(cts.Token));
            Assert.AreEqual(2, queue.Dequeue(cts.Token));
        }
        public void empty_waits_until_cancelled()
        {
            var queue = new BlockingConcurrentQueue <int>();
            var cts   = new CancellationTokenSource(TimeSpan.FromMilliseconds(30));

            Assert.Throws <OperationCanceledException>(() => queue.Dequeue(cts.Token));
        }
        public void empty_waits_until_cancelled()
        {
            var queue = new BlockingConcurrentQueue<int>();
            var cts = new CancellationTokenSource(TimeSpan.FromMilliseconds(30));

            Assert.Throws<OperationCanceledException>(() => queue.Dequeue(cts.Token));
        }
        public void WriteGreetingAsync_writes_full_NodeGreetingMessage()
        {
            var blockingQueue = new BlockingConcurrentQueue<MessageFrame>();
            var socket = new InProcSocket(RedFoxEndpoint.Empty, blockingQueue, blockingQueue);

            var negotiator = new NodeGreetingMessageQueueSocketNegotiator(socket);

            var message = new NodeGreetingMessage(NodeType.Responder);
            negotiator.WriteGreetingAsync(message, CancellationToken.None).Wait();

            Assert.AreEqual(message.Serialize(), blockingQueue.Dequeue(CancellationToken.None).RawMessage);
        }
        public void WriteGreetingAsync_writes_full_NodeGreetingMessage()
        {
            var blockingQueue = new BlockingConcurrentQueue <MessageFrame>();
            var socket        = new InProcSocket(RedFoxEndpoint.Empty, blockingQueue, blockingQueue);

            var negotiator = new NodeGreetingMessageQueueSocketNegotiator(socket);

            var message = new NodeGreetingMessage(NodeType.Responder);

            negotiator.WriteGreetingAsync(message, CancellationToken.None).Wait();

            Assert.AreEqual(message.Serialize(), blockingQueue.Dequeue(CancellationToken.None).RawMessage);
        }