예제 #1
0
        public async Task GetEntityPath_WithNamespaceConnectionStringInsteadOfEntityScopedUsingTokenCredential_Fails()
        {
            // Arrange
            var serviceBusNamespace = "arcus-messaging-integration-tests.servicebus.windows.net";
            var serviceProvider     = new ServiceCollection().BuildServiceProvider();
            var expected            = $"entity-{Guid.NewGuid()}";
            var entityType          = ServiceBusEntityType.Queue;
            var credential          = new DefaultAzureCredential();
            var options             = new AzureServiceBusMessagePumpOptions();

            var settings = new AzureServiceBusMessagePumpSettings(
                entityName: expected,
                subscriptionName: null,
                serviceBusEntity: entityType,
                serviceBusNamespace: serviceBusNamespace,
                tokenCredential: credential,
                options: options,
                serviceProvider: serviceProvider);

            // Act
            string actual = await settings.GetEntityPathAsync();

            // Assert
            Assert.Equal(expected, actual);
        }
예제 #2
0
        public void TransactionIdPropertyName_ValueIsBlank_Throws(string transactionIdPropertyName)
        {
            // Arrange
            var options = new AzureServiceBusMessagePumpOptions();

            // Act / Assert
            Assert.ThrowsAny <ArgumentException>(() => options.Correlation.TransactionIdPropertyName = transactionIdPropertyName);
        }
예제 #3
0
        public void TopicOptionsMaxConcurrentCalls_ValueIsNegative_ThrowsException()
        {
            // Arrange
            var options = new AzureServiceBusMessagePumpOptions();
            var invalidConcurrentCalls = -1;

            // Act & Assert
            Assert.Throws <ArgumentException>(() => options.MaxConcurrentCalls = invalidConcurrentCalls);
        }
예제 #4
0
        public void TransactionIdPropertyName_ValueNotBlank_Succeeds()
        {
            // Arrange
            var          options  = new AzureServiceBusMessagePumpOptions();
            const string expected = "Transaction-ID";

            // Act
            options.Correlation.TransactionIdPropertyName = expected;

            // Assert
            Assert.Equal(expected, options.Correlation.TransactionIdPropertyName);
        }
예제 #5
0
        public void TopicOptionsMaxConcurrentCalls_ValueIsAboveZero_Succeeds()
        {
            // Arrange
            var options = new AzureServiceBusMessagePumpOptions();
            var validConcurrentCalls = 1337;

            // Act
            options.MaxConcurrentCalls = validConcurrentCalls;

            // Assert
            Assert.Equal(validConcurrentCalls, options.MaxConcurrentCalls);
        }
        public void MaxConcurrentCalls_ValueIsAboveZero_Succeeds()
        {
            // Arrange
            var validConcurrentCalls = 1337;

            // Act
            var messagePumpOptions = new AzureServiceBusMessagePumpOptions {
                MaxConcurrentCalls = validConcurrentCalls
            };

            // Assert
            Assert.Equal(validConcurrentCalls, messagePumpOptions.MaxConcurrentCalls);
        }
예제 #7
0
        public void CreateOptions_WithoutServiceProviderUsingConnectionString_Fails()
        {
            // Arrange
            var entityType = ServiceBusEntityType.Topic;
            var options    = new AzureServiceBusMessagePumpOptions();

            // Act / Assert
            Assert.ThrowsAny <ArgumentException>(() => new AzureServiceBusMessagePumpSettings(
                                                     entityName: null,
                                                     subscriptionName: null,
                                                     serviceBusEntity: entityType,
                                                     getConnectionStringFromConfigurationFunc: config => "MyConnectionString",
                                                     getConnectionStringFromSecretFunc: null,
                                                     options: options,
                                                     serviceProvider: null));
        }
예제 #8
0
        public void CreateSettings_WithoutEitherConnectionStringFunctions_Fails()
        {
            // Arrange
            var entityType      = ServiceBusEntityType.Topic;
            var options         = new AzureServiceBusMessagePumpOptions();
            var serviceProvider = new ServiceCollection().BuildServiceProvider();

            Assert.ThrowsAny <ArgumentException>(() => new AzureServiceBusMessagePumpSettings(
                                                     entityName: null,
                                                     subscriptionName: null,
                                                     serviceBusEntity: entityType,
                                                     getConnectionStringFromConfigurationFunc: null,
                                                     getConnectionStringFromSecretFunc: null,
                                                     options: options,
                                                     serviceProvider: serviceProvider));
        }
예제 #9
0
        public void CreateOptions_WithoutServiceProviderUsingTokenCredential_Fails()
        {
            // Arrange
            var entityType          = ServiceBusEntityType.Queue;
            var options             = new AzureServiceBusMessagePumpOptions();
            var serviceProvider     = new ServiceCollection().BuildServiceProvider();
            var credential          = new DefaultAzureCredential();
            var serviceBusNamespace = "arcus-messaging-integration-tests.servicebus.windows.net";

            // Act / Assert
            Assert.ThrowsAny <ArgumentException>(() => new AzureServiceBusMessagePumpSettings(
                                                     entityName: null,
                                                     subscriptionName: null,
                                                     serviceBusNamespace: serviceBusNamespace,
                                                     serviceBusEntity: entityType,
                                                     tokenCredential: credential,
                                                     options: options,
                                                     serviceProvider: null));
        }
예제 #10
0
        public void CreateSettings_WithEntityScopedUsingConnectionString_Succeeds()
        {
            // Arrange
            var entityType                = ServiceBusEntityType.Queue;
            var options                   = new AzureServiceBusMessagePumpOptions();
            var serviceProvider           = new ServiceCollection().BuildServiceProvider();
            var namespaceConnectionString =
                $"Endpoint=sb://arcus-messaging-integration-tests.servicebus.windows.net/;SharedAccessKeyName=MyAccessKeyName;SharedAccessKey={Guid.NewGuid()}";

            // Act / Assert
            var settings = new AzureServiceBusMessagePumpSettings(
                entityName: null,
                subscriptionName: null,
                serviceBusEntity: entityType,
                getConnectionStringFromConfigurationFunc: null,
                getConnectionStringFromSecretFunc: secretProvider => Task.FromResult(namespaceConnectionString),
                options: options,
                serviceProvider: serviceProvider);
        }
예제 #11
0
        public void CreateSettings_WithTokenCredential_Succeeds()
        {
            // Arrange
            var serviceBusNamespace = "arcus-messaging-integration-tests.servicebus.windows.net";
            var serviceProvider     = new ServiceCollection().BuildServiceProvider();
            var expected            = $"entity-{Guid.NewGuid()}";
            var entityType          = ServiceBusEntityType.Queue;
            var credential          = new DefaultAzureCredential();
            var options             = new AzureServiceBusMessagePumpOptions();

            // Act / Assert
            var settings = new AzureServiceBusMessagePumpSettings(
                entityName: expected,
                subscriptionName: null,
                serviceBusEntity: entityType,
                serviceBusNamespace: serviceBusNamespace,
                tokenCredential: credential,
                options: options,
                serviceProvider: serviceProvider);
        }
예제 #12
0
        public async Task GetEntityPath_WithNamespaceConnectionStringInsteadOfEntityScopedUsingConnectionString_Fails()
        {
            // Arrange
            var entityType      = ServiceBusEntityType.Queue;
            var options         = new AzureServiceBusMessagePumpOptions();
            var secretProvider  = new EnvironmentVariableSecretProvider();
            var serviceProvider = new ServiceCollection()
                                  .AddSingleton <ISecretProvider>(secretProvider)
                                  .BuildServiceProvider();
            var namespaceConnectionString =
                $"Endpoint=sb://arcus-messaging-integration-tests.servicebus.windows.net/;SharedAccessKeyName=MyAccessKeyName;SharedAccessKey={Guid.NewGuid()}";

            var settings = new AzureServiceBusMessagePumpSettings(
                entityName: null,
                subscriptionName: null,
                serviceBusEntity: entityType,
                getConnectionStringFromConfigurationFunc: null,
                getConnectionStringFromSecretFunc: secretProvider => Task.FromResult(namespaceConnectionString),
                options: options,
                serviceProvider: serviceProvider);

            // Act
            await Assert.ThrowsAnyAsync <ArgumentException>(() => settings.GetEntityPathAsync());
        }