public void TranslateServiceExceptionTranslatesOperationCanceledWithEmbeddedGeneralException()
        {
            var eventHub   = "someHub";
            var embedded   = new ArgumentException();
            var exception  = new OperationCanceledException("oops", embedded);
            var translated = exception.TranslateServiceException(eventHub);

            Assert.That(translated, Is.Not.Null, "An exception should have been returned.");
            Assert.That(translated, Is.SameAs(embedded), "The embedded (inner) exception should have been returned.");
        }
        public void TranslateServiceExceptionTranslatesOperationCanceledWithoutEmbeddedExceptions()
        {
            var eventHub   = "someHub";
            var exception  = new OperationCanceledException();
            var translated = exception.TranslateServiceException(eventHub);

            Assert.That(translated, Is.Not.Null, "An exception should have been returned.");

            var eventHubsException = translated as EventHubsException;

            Assert.That(eventHubsException, Is.Not.Null, "The exception type should be appropriate for the `Server Busy` scenario.");
            Assert.That(eventHubsException.Reason, Is.EqualTo(EventHubsException.FailureReason.ServiceTimeout), "The exception reason should indicate a service timeout.");
            Assert.That(eventHubsException.EventHubName, Is.EqualTo(eventHub), "The Event Hub name should match.");
        }
        public void TranslateServiceExceptionTranslatesOperationCanceledWithEmbeddedAmqpException()
        {
            var eventHub  = "someHub";
            var exception = new OperationCanceledException("oops", AmqpError.CreateExceptionForError(new Error {
                Condition = AmqpError.ServerBusyError
            }, eventHub));
            var translated = exception.TranslateServiceException(eventHub);

            Assert.That(translated, Is.Not.Null, "An exception should have been returned.");

            var eventHubsException = translated as EventHubsException;

            Assert.That(eventHubsException, Is.Not.Null, "The exception type should be appropriate for the `Server Busy` scenario.");
            Assert.That(eventHubsException.Reason, Is.EqualTo(EventHubsException.FailureReason.ServiceBusy), "The exception reason should indicate `Server Busy`.");
            Assert.That(eventHubsException.EventHubName, Is.EqualTo(eventHub), "The Event Hub name should match.");
        }