public void CreateConsumerCreatesDefaultWhenOptionsAreNotSet() { var clientOptions = new EventHubClientOptions { Retry = new ExponentialRetry(TimeSpan.FromSeconds(1), TimeSpan.FromSeconds(3), 5), DefaultTimeout = TimeSpan.FromHours(24) }; var expectedOptions = new EventHubConsumerOptions { OwnerLevel = 251, Identifier = "Bob", PrefetchCount = 600, Retry = clientOptions.Retry, DefaultMaximumReceiveWaitTime = clientOptions.DefaultTimeout }; var expectedConsumerGroup = "SomeGroup"; var expectedPartition = "56767"; var expectedPosition = EventPosition.FromSequenceNumber(123); var connectionString = "Endpoint=value.com;SharedAccessKeyName=[value];SharedAccessKey=[value];EntityPath=[value]"; var mockClient = new ReadableOptionsMock(connectionString, clientOptions); mockClient.CreateConsumer(expectedConsumerGroup, expectedPartition, expectedPosition, expectedOptions); var actualOptions = mockClient.ConsumerOptions; Assert.That(actualOptions, Is.Not.Null, "The consumer options should have been set."); Assert.That(actualOptions, Is.Not.SameAs(expectedOptions), "A clone of the options should have been made."); Assert.That(actualOptions.OwnerLevel, Is.EqualTo(expectedOptions.OwnerLevel), "The owner levels should match."); Assert.That(actualOptions.Identifier, Is.EqualTo(expectedOptions.Identifier), "The identifiers should match."); Assert.That(actualOptions.PrefetchCount, Is.EqualTo(expectedOptions.PrefetchCount), "The prefetch counts should match."); Assert.That(ExponentialRetry.HaveSameConfiguration((ExponentialRetry)actualOptions.Retry, (ExponentialRetry)expectedOptions.Retry), "The retries should match."); Assert.That(actualOptions.MaximumReceiveWaitTimeOrDefault, Is.EqualTo(expectedOptions.MaximumReceiveWaitTimeOrDefault), "The wait times should match."); }
public void CreateConsumerCreatesDefaultWhenNoOptionsArePassed() { var clientOptions = new EventHubClientOptions { Retry = new ExponentialRetry(TimeSpan.FromSeconds(1), TimeSpan.FromSeconds(3), 5), DefaultTimeout = TimeSpan.FromHours(24) }; var expectedOptions = new EventHubConsumerOptions { Retry = clientOptions.Retry, DefaultMaximumReceiveWaitTime = clientOptions.DefaultTimeout }; var expectedConsumerGroup = EventHubConsumer.DefaultConsumerGroup; var expectedPartition = "56767"; var expectedPosition = EventPosition.FromEnqueuedTime(DateTime.Parse("2015-10-27T12:00:00Z")); var connectionString = "Endpoint=value.com;SharedAccessKeyName=[value];SharedAccessKey=[value];EntityPath=[value]"; var mockClient = new ReadableOptionsMock(connectionString, clientOptions); mockClient.CreateConsumer(expectedConsumerGroup, expectedPartition, expectedPosition); var actualOptions = mockClient.ConsumerOptions; Assert.That(actualOptions, Is.Not.Null, "The consumer options should have been set."); Assert.That(actualOptions.OwnerLevel, Is.EqualTo(expectedOptions.OwnerLevel), "The owner levels should match."); Assert.That(actualOptions.Identifier, Is.EqualTo(expectedOptions.Identifier), "The identifiers should match."); Assert.That(actualOptions.PrefetchCount, Is.EqualTo(expectedOptions.PrefetchCount), "The prefetch counts should match."); Assert.That(ExponentialRetry.HaveSameConfiguration((ExponentialRetry)actualOptions.Retry, (ExponentialRetry)expectedOptions.Retry), "The retries should match."); Assert.That(actualOptions.MaximumReceiveWaitTimeOrDefault, Is.EqualTo(expectedOptions.MaximumReceiveWaitTimeOrDefault), "The wait times should match."); }