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); }
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()); }