public void Queue_and_dequeue_one_item_should_return_the_same_and_empty_the_queue()
        {
            var expected = Encoding.ASCII.GetBytes("Hello world");
            var actual   = new List <byte[]>();

            _queue.Enqueue(expected);
            _queue.FlushWriter();
            _queue.Dequeue(actual, 100);

            actual.Count.Should().Be(1);
            actual[0].ShouldBeEquivalentTo(expected);
        }
        public void StoreItems()
        {
            const int ItemsToEnqueue = 300000;

            var enqueueOnePerFlush = new Stopwatch();

            enqueueOnePerFlush.Start();
            for (int i = 0; i < ItemsToEnqueue; i++)
            {
                _queue.Enqueue(new byte[2000]);
                _queue.FlushWriter();
            }
            enqueueOnePerFlush.Stop();
            Console.WriteLine("Enqueue items: " + enqueueOnePerFlush.ElapsedMilliseconds + "ms = " + (ItemsToEnqueue * 1000 / enqueueOnePerFlush.ElapsedMilliseconds) + "items/s");

            var enqueueBatch = new Stopwatch();

            enqueueBatch.Start();
            for (int i = 0; i < ItemsToEnqueue; i++)
            {
                _queue.Enqueue(new byte[2000]);
                if (i % 100 == 0)
                {
                    _queue.FlushWriter();
                }
            }
            _queue.FlushWriter();
            enqueueBatch.Stop();
            Console.WriteLine("Enqueue items (batching): " + enqueueBatch.ElapsedMilliseconds + "ms = " + (ItemsToEnqueue * 1000 / enqueueBatch.ElapsedMilliseconds) + "items/s");

            var dequeue = new Stopwatch();

            dequeue.Start();
            var items = new List <byte[]>();

            for (int i = 0; i < ItemsToEnqueue * 2; i++)
            {
                _queue.Dequeue(items, 100);
            }
            dequeue.Stop();
            Console.WriteLine("Dequeue items: " + dequeue.ElapsedMilliseconds + "ms = " + (ItemsToEnqueue * 2 * 1000 / dequeue.ElapsedMilliseconds) + "items/s");
        }