public void GetRetryFromRejectedReturnsNullIfNoError()
        {
            var rejected = new Rejected();

            TimeSpan?actual = ProvisioningErrorDetailsAmqp.GetRetryAfterFromRejection(rejected, s_defaultInterval);

            Assert.IsNull(actual);
        }
        public void GetRetryFromRejectedReturnsNullIfNoErrorInfoEntries()
        {
            Rejected rejected = new Rejected();

            rejected.Error      = new Error();
            rejected.Error.Info = new Fields();

            TimeSpan?actual = ProvisioningErrorDetailsAmqp.GetRetryAfterFromRejection(rejected, defaultInterval);

            Assert.IsNull(actual);
        }
        public void GetRetryFromRejectedFallsBackToDefaultIfRetryAfterProvidedIs0()
        {
            int      expectedSeconds = 0;
            Rejected rejected        = new Rejected();

            rejected.Error      = new Error();
            rejected.Error.Info = new Fields();
            rejected.Error.Info.Add(new Azure.Amqp.Encoding.AmqpSymbol("Retry-After"), expectedSeconds);

            TimeSpan?actual = ProvisioningErrorDetailsAmqp.GetRetryAfterFromRejection(rejected, defaultInterval);

            Assert.IsNotNull(actual);
            Assert.AreEqual(actual?.Seconds, defaultInterval.Seconds);
        }
        public void GetRetryFromRejectedSuccess()
        {
            int      expectedSeconds = 32;
            Rejected Rejected        = new Rejected();

            Rejected.Error      = new Error();
            Rejected.Error.Info = new Fields();
            Rejected.Error.Info.Add(new AmqpSymbol("Retry-After"), expectedSeconds);

            TimeSpan?actual = ProvisioningErrorDetailsAmqp.GetRetryAfterFromRejection(Rejected, defaultInterval);

            Assert.IsNotNull(actual);
            Assert.AreEqual(actual?.Seconds, expectedSeconds);
        }
        public void GetRetryFromRejectedFallsBackToDefaultIfRetryAfterProvidedIs0()
        {
            int expectedSeconds = 0;
            var rejected        = new Rejected
            {
                Error = new Error()
            };

            rejected.Error.Info = new Fields
            {
                { new AmqpSymbol("Retry-After"), expectedSeconds }
            };

            TimeSpan?actual = ProvisioningErrorDetailsAmqp.GetRetryAfterFromRejection(rejected, s_defaultInterval);

            Assert.IsNotNull(actual);
            Assert.AreEqual(actual?.Seconds, s_defaultInterval.Seconds);
        }