Ejemplo n.º 1
0
        public async Task Should_create_a_subscription_based_on_event_type_full_name_for_an_event_name_reused_across_multiple_namespaces()
        {
            var namespaceManager = new NamespaceManagerAdapterInternal(NamespaceManager.CreateFromConnectionString(AzureServiceBusConnectionString.Value));
            await namespaceManager.CreateSubscription(new SubscriptionDescription(topicPath, nameof(Ns1.ReusedEvent)), new SqlSubscriptionFilter(typeof(Ns1.ReusedEvent)).Serialize());

            var creator   = new AzureServiceBusSubscriptionCreatorV6(new TopologySubscriptionSettings());
            var metadata1 = new SubscriptionMetadataInternal
            {
                SubscriptionNameBasedOnEventWithNamespace = typeof(Ns1.ReusedEvent).FullName,
                Description = Guid.NewGuid().ToString()
            };
            var metadata2 = new SubscriptionMetadataInternal
            {
                SubscriptionNameBasedOnEventWithNamespace = typeof(Ns2.ReusedEvent).FullName,
                Description = Guid.NewGuid().ToString()
            };
            var shortedSubscriptionName = typeof(Ns2.ReusedEvent).FullName;

            await creator.Create(topicPath, nameof(Ns1.ReusedEvent), metadata1, new SqlSubscriptionFilter(typeof(Ns1.ReusedEvent)).Serialize(), namespaceManager);

            await creator.Create(topicPath, nameof(Ns2.ReusedEvent), metadata2, new SqlSubscriptionFilter(typeof(Ns2.ReusedEvent)).Serialize(), namespaceManager);

            var subscriptionDescription = await namespaceManager.GetSubscription(topicPath, shortedSubscriptionName);

            Assert.AreEqual(metadata2.Description, subscriptionDescription.UserMetadata);
            Assert.AreEqual(metadata2.SubscriptionNameBasedOnEventWithNamespace, subscriptionDescription.Name);

            await namespaceManager.DeleteSubscription(new SubscriptionDescription(topicPath, nameof(Ns1.ReusedEvent)));

            await namespaceManager.DeleteSubscription(new SubscriptionDescription(topicPath, nameof(Ns2.ReusedEvent)));
        }
Ejemplo n.º 2
0
        public async Task Should_properly_set_ForwardTo_on_the_created_entity()
        {
            var namespaceManager = new NamespaceManagerAdapterInternal(NamespaceManager.CreateFromConnectionString(AzureServiceBusConnectionString.Value));
            await namespaceManager.CreateSubscription(new SubscriptionDescription(topicPath, nameof(Ns1.ReusedEvent)), new SqlSubscriptionFilter(typeof(Ns1.ReusedEvent)).Serialize());

            var topicCreator     = new AzureServiceBusTopicCreator(new TopologyTopicSettings());
            var topicToForwardTo = await topicCreator.Create("topic2forward2", namespaceManager);

            var creator   = new AzureServiceBusSubscriptionCreatorV6(new TopologySubscriptionSettings());
            var metadata1 = new SubscriptionMetadataInternal
            {
                SubscriptionNameBasedOnEventWithNamespace = typeof(Ns1.ReusedEvent).FullName,
                Description = Guid.NewGuid().ToString()
            };

            var subscriptionName = nameof(Ns1.ReusedEvent);

            await creator.Create(topicPath, subscriptionName, metadata1, new SqlSubscriptionFilter(typeof(Ns1.ReusedEvent)).Serialize(), namespaceManager, topicToForwardTo.Path);

            // create again without forward to
            await creator.Create(topicPath, subscriptionName, metadata1, new SqlSubscriptionFilter(typeof(Ns1.ReusedEvent)).Serialize(), namespaceManager);

            var subscriptionDescription = await namespaceManager.GetSubscription(topicPath, subscriptionName);

            Assert.IsNull(subscriptionDescription.ForwardTo);

            await namespaceManager.DeleteSubscription(new SubscriptionDescription(topicPath, subscriptionName));

            await namespaceManager.DeleteTopic(topicToForwardTo.Path);
        }
Ejemplo n.º 3
0
        public async Task Should_not_create_create_a_duplicate_subscription__issue_811()
        {
            var nativeManager    = NamespaceManager.CreateFromConnectionString(AzureServiceBusConnectionString.Value);
            var namespaceManager = new NamespaceManagerAdapterInternal(nativeManager);

            var topicForTest = $"{topicPath}_issue811";

            try
            {
                if (!await nativeManager.TopicExistsAsync(topicForTest))
                {
                    await nativeManager.CreateTopicAsync(new TopicDescription(topicForTest));
                }

                var subscriptionName = nameof(SomeEvent);

                await namespaceManager.CreateSubscription(new SubscriptionDescription(topicForTest, subscriptionName), new SqlSubscriptionFilter_UsedPriorToVersion9(typeof(SomeEvent)).Serialize());

                var creator  = new AzureServiceBusSubscriptionCreatorV6(new TopologySubscriptionSettings());
                var metadata = new SubscriptionMetadataInternal
                {
                    SubscriptionNameBasedOnEventWithNamespace = typeof(SomeEvent).FullName,
                    Description = Guid.NewGuid().ToString()
                };
                var properSqlFilter = new SqlSubscriptionFilter(typeof(SomeEvent)).Serialize();

                await creator.Create(topicForTest, subscriptionName, metadata, properSqlFilter, namespaceManager);

                var foundSubcriptions = await nativeManager.GetSubscriptionsAsync(topicForTest);

                Assert.AreEqual(1, foundSubcriptions.Count());
            }
            finally
            {
                await nativeManager.DeleteTopicAsync(topicForTest);
            }
        }