public void Execute_CommonApiException_MapsToProperAzureException(string exceptionName, string errorCode, int httpStatus, string errorMessage)
 {
     //arrange
     string expectedExceptionName = exceptionName + "AzureException";
     var expectedUri = "test://common-api-errors.abc/whatever/";
     var expectedRawRequest = new TestableWebRequest(new Uri(expectedUri));
     expectedRawRequest.EnqueueResponse((HttpStatusCode)httpStatus, errorCode, ErrorContentFor(errorCode, errorMessage), true);
     TestableWebRequestCreateFactory.GetFactory().AddRequest(expectedRawRequest);
     var request = new RequestWithErrorPayload(new SettingsFake(), expectedUri, "GET", StorageServiceType.QueueService);
     request.RetryPolicy = new RetryPolicy<ExceptionRetryStrategy>(0);
     try
     {
         //act
         var response = request.Execute();
     }
     catch (AzureException ae)
     {
         //assert
         Assert.AreEqual(expectedExceptionName, ae.GetType().Name);
     }
 }
Exemple #2
0
        public void Execute_CommonApiException_MapsToProperAzureException(string exceptionName, string errorCode, int httpStatus, string errorMessage)
        {
            //arrange
            string expectedExceptionName = exceptionName + "AzureException";
            var    expectedUri           = "test://common-api-errors.abc/whatever/";
            var    expectedRawRequest    = new TestableWebRequest(new Uri(expectedUri));

            expectedRawRequest.EnqueueResponse((HttpStatusCode)httpStatus, errorCode, ErrorContentFor(errorCode, errorMessage), true);
            TestableWebRequestCreateFactory.GetFactory().AddRequest(expectedRawRequest);
            var request = new RequestWithErrorPayload(new SettingsFake(), expectedUri, "GET", StorageServiceType.QueueService);

            request.RetryPolicy = new RetryPolicy <ExceptionRetryStrategy>(0);
            try
            {
                //act
                var response = request.Execute();
            }
            catch (AzureException ae)
            {
                //assert
                Assert.AreEqual(expectedExceptionName, ae.GetType().Name);
            }
        }