public void RespectsConnectionOptionsForProducer(string expectedPathName, string connectionString) { var testEndpoint = new Uri("http://mycustomendpoint.com"); EventHubOptions options = new EventHubOptions { ConnectionOptions = new EventHubConnectionOptions { CustomEndpointAddress = testEndpoint }, RetryOptions = new EventHubsRetryOptions { MaximumRetries = 10 } }; options.AddSender(expectedPathName, connectionString); var configuration = CreateConfiguration(); var factory = new EventHubClientFactory(configuration, Mock.Of <AzureComponentFactory>(), Options.Create(options), new DefaultNameResolver(configuration)); var producer = factory.GetEventHubProducerClient(expectedPathName, null); EventHubConnection connection = (EventHubConnection)typeof(EventHubProducerClient).GetProperty("Connection", BindingFlags.NonPublic | BindingFlags.Instance) .GetValue(producer); EventHubConnectionOptions connectionOptions = (EventHubConnectionOptions)typeof(EventHubConnection).GetProperty("Options", BindingFlags.NonPublic | BindingFlags.Instance).GetValue(connection); Assert.AreEqual(testEndpoint, connectionOptions.CustomEndpointAddress); Assert.AreEqual(expectedPathName, producer.EventHubName); EventHubProducerClientOptions producerOptions = (EventHubProducerClientOptions)typeof(EventHubProducerClient).GetProperty("Options", BindingFlags.NonPublic | BindingFlags.Instance).GetValue(producer); Assert.AreEqual(10, producerOptions.RetryOptions.MaximumRetries); Assert.AreEqual(expectedPathName, producer.EventHubName); }
public void EntityPathInConnectionString(string expectedPathName, string connectionString) { EventHubOptions options = new EventHubOptions(); // Test sender options.AddSender("k1", connectionString); var client = options.GetEventHubClient("k1", null); Assert.Equal(expectedPathName, client.EventHubName); }
public void EntityPathInConnectionString(string expectedPathName, string connectionString) { EventHubOptions options = new EventHubOptions(); // Test sender options.AddSender("k1", connectionString); var configuration = CreateConfiguration(); var factory = new EventHubClientFactory(configuration, Mock.Of <AzureComponentFactory>(), Options.Create(options), new DefaultNameResolver(configuration)); var client = factory.GetEventHubProducerClient("k1", null); Assert.AreEqual(expectedPathName, client.EventHubName); }