public async Task Should_not_update_properties_of_an_existing_system_queue()
        {
            var queuePath = "errorQ";

            var namespaceManager = new NamespaceManagerAdapterInternal(NamespaceManager.CreateFromConnectionString(AzureServiceBusConnectionString.Value));
            await namespaceManager.DeleteQueue(queuePath).ConfigureAwait(false);

            if (!await namespaceManager.QueueExists(queuePath).ConfigureAwait(false))
            {
                await namespaceManager.CreateQueue(new QueueDescription(queuePath)).ConfigureAwait(false);
            }

            var settings = DefaultConfigurationValues.Apply(SettingsHolderFactory.BuildWithSerializer());

            settings.Set(WellKnownConfigurationKeys.Core.RecoverabilityNumberOfImmediateRetries, 2);
            var queueBindings = new QueueBindings();

            queueBindings.BindSending(queuePath);
            settings.Set <QueueBindings>(queueBindings);

            var extensions = new TransportExtensions <AzureServiceBusTransport>(settings);

            extensions.Queues().LockDuration(TimeSpan.FromMinutes(4));

            var creator = new AzureServiceBusQueueCreator(settings.Get <TopologySettings>().QueueSettings, settings);

            await creator.Create(queuePath, namespaceManager);

            var real = await namespaceManager.GetQueue(queuePath);

            Assert.That(real.LockDuration, Is.EqualTo(TimeSpan.FromSeconds(60)));

            //cleanup
            await namespaceManager.DeleteQueue(queuePath);
        }
        public async Task Uses_queue_description_when_provided_by_user()
        {
            var settings = DefaultConfigurationValues.Apply(SettingsHolderFactory.BuildWithSerializer());

            var extensions       = new TransportExtensions <AzureServiceBusTransport>(settings);
            var namespaceManager = new NamespaceManagerAdapterInternal(NamespaceManager.CreateFromConnectionString(AzureServiceBusConnectionString.Value));

            var userQueueDescriptionFactoryWasInvoked = false;

            extensions.Queues().DescriptionCustomizer(qd => userQueueDescriptionFactoryWasInvoked = true);

            var creator = new AzureServiceBusQueueCreator(settings.Get <TopologySettings>().QueueSettings, settings);

            await creator.Create("myqueue", namespaceManager);

            Assert.IsTrue(await namespaceManager.QueueExists("myqueue"));
            Assert.IsTrue(userQueueDescriptionFactoryWasInvoked);

            //cleanup
            await namespaceManager.DeleteQueue("myqueue");
        }
        public void TopicSetup()
        {
            var namespaceManager = new NamespaceManagerAdapterInternal(NamespaceManager.CreateFromConnectionString(AzureServiceBusConnectionString.Value));

            if (!namespaceManager.TopicExists(topicPath).GetAwaiter().GetResult())
            {
                namespaceManager.CreateTopic(new TopicDescription(topicPath)).GetAwaiter().GetResult();
            }
            if (!namespaceManager.QueueExists(forwardToQueue).GetAwaiter().GetResult())
            {
                namespaceManager.CreateQueue(new QueueDescription(forwardToQueue)).GetAwaiter().GetResult();
            }

            namespaceManager = new NamespaceManagerAdapterInternal(NamespaceManager.CreateFromConnectionString(AzureServiceBusConnectionString.Fallback));
            if (!namespaceManager.TopicExists(topicPath).GetAwaiter().GetResult())
            {
                namespaceManager.CreateTopic(new TopicDescription(topicPath)).GetAwaiter().GetResult();
            }
            if (!namespaceManager.QueueExists(forwardToQueue).GetAwaiter().GetResult())
            {
                namespaceManager.CreateQueue(new QueueDescription(forwardToQueue)).GetAwaiter().GetResult();
            }
        }