public void CreateConsumerCreatesDefaultWhenOptionsAreNotSet() { var retryOptions = new RetryOptions { MaximumRetries = 99, MaximumDelay = TimeSpan.FromHours(72), Delay = TimeSpan.FromSeconds(27) }; var expectedOptions = new EventHubConsumerClientOptions { OwnerLevel = 251, PrefetchCount = 600, RetryOptions = retryOptions, DefaultMaximumReceiveWaitTime = TimeSpan.FromSeconds(123) }; var clientOptions = new EventHubConnectionOptions(); 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.CreateTransportConsumer(expectedConsumerGroup, expectedPartition, expectedPosition, expectedOptions); EventHubConsumerClientOptions 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.PrefetchCount, Is.EqualTo(expectedOptions.PrefetchCount), "The prefetch counts should match."); Assert.That(actualOptions.RetryOptions.IsEquivalentTo(expectedOptions.RetryOptions), Is.True, "The retries should match."); Assert.That(actualOptions.MaximumReceiveWaitTimeOrDefault, Is.EqualTo(expectedOptions.MaximumReceiveWaitTimeOrDefault), "The wait times should match."); }
public void CreateConsumerCreatesDefaultWhenNoOptionsArePassed() { var expectedOptions = new EventHubConsumerClientOptions(); var expectedConsumerGroup = EventHubConsumerClient.DefaultConsumerGroupName; var expectedPartition = "56767"; var expectedPosition = EventPosition.FromEnqueuedTime(DateTimeOffset.Parse("2015-10-27T12:00:00Z")); var connectionString = "Endpoint=value.com;SharedAccessKeyName=[value];SharedAccessKey=[value];EntityPath=[value]"; var mockClient = new ReadableOptionsMock(connectionString, new EventHubConnectionOptions()); mockClient.CreateTransportConsumer(expectedConsumerGroup, expectedPartition, expectedPosition); EventHubConsumerClientOptions 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.PrefetchCount, Is.EqualTo(expectedOptions.PrefetchCount), "The prefetch counts should match."); Assert.That(actualOptions.RetryOptions.IsEquivalentTo(expectedOptions.RetryOptions), Is.True, "The retries should match."); Assert.That(actualOptions.MaximumReceiveWaitTimeOrDefault, Is.EqualTo(expectedOptions.MaximumReceiveWaitTimeOrDefault), "The wait times should match."); }