Exemplo n.º 1
0
        public void CalulateTryTimeoutRespectsOptions(int attemptCount)
        {
            var timeout = TimeSpan.FromSeconds(5);
            var options = new RetryOptions {
                TryTimeout = timeout
            };
            var policy = new BasicRetryPolicy(options);

            Assert.That(policy.CalculateTryTimeout(attemptCount), Is.EqualTo(options.TryTimeout));
        }
Exemplo n.º 2
0
        public void UpdateRetryPolicyUpdatesTheOperationTimeout()
        {
            var initialPolicy = new BasicRetryPolicy(new RetryOptions {
                TryTimeout = TimeSpan.FromSeconds(17)
            });
            var initialTimeout = initialPolicy.CalculateTryTimeout(0);
            var consumer       = new AmqpEventHubConsumer("aHub", "$DEFAULT", "0", EventPosition.Earliest, new EventHubConsumerOptions(), Mock.Of <AmqpConnectionScope>(), Mock.Of <AmqpMessageConverter>(), initialPolicy, null);

            Assert.That(GetTimeout(consumer), Is.EqualTo(initialTimeout), "The initial timeout should match");

            var newPolicy = new BasicRetryPolicy(new RetryOptions {
                TryTimeout = TimeSpan.FromMilliseconds(50)
            });
            TimeSpan newTimeout = newPolicy.CalculateTryTimeout(0);

            consumer.UpdateRetryPolicy(newPolicy);
            Assert.That(GetTimeout(consumer), Is.EqualTo(newTimeout), "The updated timeout should match");
        }
Exemplo n.º 3
0
        public void UpdateRetryPolicyUpdatesTheOperationTimeout()
        {
            var initialPolicy = new BasicRetryPolicy(new RetryOptions {
                TryTimeout = TimeSpan.FromSeconds(17)
            });
            TimeSpan initialTimeout = initialPolicy.CalculateTryTimeout(0);
            var      client         = new AmqpEventHubClient("my.eventhub.com", "somePath", Mock.Of <TokenCredential>(), new EventHubClientOptions(), initialPolicy);

            Assert.That(GetTimeout(client), Is.EqualTo(initialTimeout), "The initial timeout should match");

            var newPolicy = new BasicRetryPolicy(new RetryOptions {
                TryTimeout = TimeSpan.FromMilliseconds(50)
            });
            TimeSpan newTimeout = newPolicy.CalculateTryTimeout(0);

            client.UpdateRetryPolicy(newPolicy);
            Assert.That(GetTimeout(client), Is.EqualTo(newTimeout), "The updated timeout should match");
        }