/// <summary>
        /// Block to track the operation to completion.
        /// Waits till the status of the operation becomes something other than InProgress.
        /// </summary>
        /// <param name="response">Response of the operation returned by the service.</param>
        /// <param name="getOpStatus">Delegate method to fetch the operation status of the operation.</param>
        /// <returns>Operation status of the operation once it completes.</returns>
        public static T GetOperationStatus <T, S>(RestAzureNS.AzureOperationResponse <S> response,
                                                  Func <string, RestAzureNS.AzureOperationResponse <T> > getOpStatus)
            where T : ServiceClientModel.OperationStatus
        {
            var operationId = response.Response.Headers.GetAzureAsyncOperationId();

            var opStatusResponse = getOpStatus(operationId);

            string testMode = Environment.GetEnvironmentVariable("AZURE_TEST_MODE");

            while (opStatusResponse.Body.Status ==
                   ServiceClientModel.OperationStatusValues.InProgress)
            {
                if (!TestMockSupport.RunningMocked)
                {
                    TestMockSupport.Delay(_defaultSleepForOperationTracking * 1000);
                }
                if (String.Compare(testMode, "Record", StringComparison.OrdinalIgnoreCase) == 0)
                {
                    Thread.Sleep(5000);
                }
                opStatusResponse = getOpStatus(operationId);
            }

            opStatusResponse = getOpStatus(operationId);

            return(opStatusResponse.Body);
        }
        /// <summary>
        /// Block to track the operation to completion.
        /// Waits till the HTTP status code of the operation becomes something other than Accepted.
        /// </summary>
        /// <param name="response">Response of the operation returned by the service.</param>
        /// <param name="getOpStatus">Delegate method to fetch the operation status of the operation.</param>
        /// <returns>Result of the operation once it completes.</returns>
        public static RestAzureNS.AzureOperationResponse <T> GetOperationResult <T>(
            RestAzureNS.AzureOperationResponse <T> response,
            Func <string, RestAzureNS.AzureOperationResponse <T> > getOpStatus)
            where T : ServiceClientModel.ProtectionContainerResource
        {
            var operationId = response.Response.Headers.GetOperationResultId();

            var opStatusResponse = getOpStatus(operationId);

            string testMode = Environment.GetEnvironmentVariable("AZURE_TEST_MODE");

            while (opStatusResponse.Response.StatusCode == SystemNet.HttpStatusCode.Accepted)
            {
                if (!TestMockSupport.RunningMocked)
                {
                    TestMockSupport.Delay(_defaultSleepForOperationTracking * 1000);
                }
                if (String.Compare(testMode, "Record", StringComparison.OrdinalIgnoreCase) == 0)
                {
                    Thread.Sleep(5000);
                }

                opStatusResponse = getOpStatus(operationId);
            }

            opStatusResponse = getOpStatus(operationId);

            return(opStatusResponse);
        }
示例#3
0
        /// <summary>
        /// Block to track the operation to completion.
        /// Waits till the status of the operation becomes something other than InProgress.
        /// </summary>
        /// <param name="response">Response of the operation returned by the service.</param>
        /// <param name="getOpStatus">Delegate method to fetch the operation status of the operation.</param>
        /// <returns>Operation status of the operation once it completes.</returns>
        public static T GetOperationStatus <T, S>(RestAzureNS.AzureOperationResponse <S> response,
                                                  Func <string, RestAzureNS.AzureOperationResponse <T> > getOpStatus)
            where T : ServiceClientModel.OperationStatus
        {
            var operationId = response.Response.Headers.GetAzureAsyncOperationId();

            var opStatusResponse = getOpStatus(operationId);

            while (opStatusResponse.Body.Status ==
                   ServiceClientModel.OperationStatusValues.InProgress)
            {
                TestMockSupport.Delay(_defaultSleepForOperationTracking * 1000);

                opStatusResponse = getOpStatus(operationId);
            }

            opStatusResponse = getOpStatus(operationId);

            return(opStatusResponse.Body);
        }
示例#4
0
        /// <summary>
        /// Block to track the operation to completion.
        /// Waits till the HTTP status code of the operation becomes something other than Accepted.
        /// </summary>
        /// <param name="response">Response of the operation returned by the service.</param>
        /// <param name="getOpStatus">Delegate method to fetch the operation status of the operation.</param>
        /// <returns>Result of the operation once it completes.</returns>
        public static RestAzureNS.AzureOperationResponse <T> GetOperationResult <T>(
            RestAzureNS.AzureOperationResponse <T> response,
            Func <string, RestAzureNS.AzureOperationResponse <T> > getOpStatus)
            where T : ServiceClientModel.ProtectionContainerResource
        {
            var operationId = response.Response.Headers.GetOperationResultId();

            var opStatusResponse = getOpStatus(operationId);

            while (opStatusResponse.Response.StatusCode == SystemNet.HttpStatusCode.Accepted)
            {
                TestMockSupport.Delay(_defaultSleepForOperationTracking * 1000);

                opStatusResponse = getOpStatus(operationId);
            }

            opStatusResponse = getOpStatus(operationId);

            return(opStatusResponse);
        }