public void CancelReceiveAsyncShouldStopBeforeTimeout()
        {
            var name = $"IntegrationTest_{UniqueKeyUtility.Generate()}";

            try
            {
                using (var queue = new LocaleQueue(NullLogger.Instance, _messageQueueManager, _messageQueueTransactionFactory, name, true, LocaleQueueMode.DurableCreate, true, AccessMode.Receive))
                {
                    var cancellationTokenSource = new CancellationTokenSource();
                    var stopwatch = new Stopwatch();

                    stopwatch.Start();
                    var task = queue.ReceiveAsync(1000, cancellationTokenSource.Token);
                    cancellationTokenSource.CancelAfter(500);
                    try
                    {
                        task.Result?.Message.Should().BeNull();
                    }
                    catch (Exception)
                    {
                        // ignored
                    }

                    stopwatch.Stop();
                    stopwatch.ElapsedMilliseconds.Should().BeInRange(400, 711);
                }
            }
            finally
            {
                _messageQueueManager.Delete(name, true);
            }
        }
        public void ReceiveAsyncFromEmptyQueueShouldTimeout()
        {
            var name = $"IntegrationTest_{UniqueKeyUtility.Generate()}";

            try
            {
                using (var queue = new LocaleQueue(NullLogger.Instance, _messageQueueManager, _messageQueueTransactionFactory, name, true, LocaleQueueMode.DurableCreate, true, AccessMode.Receive))
                {
                    var stopwatch = new Stopwatch();
                    stopwatch.Start();
                    var task = queue.ReceiveAsync(1000, _cancellationToken);
                    stopwatch.ElapsedMilliseconds.Should().BeLessThan(900);
                    task.Result?.Message.Should().BeNull();
                    stopwatch.ElapsedMilliseconds.Should().BeGreaterThan(900);
                }
            }
            finally
            {
                _messageQueueManager.Delete(name, true);
            }
        }