Exemplo n.º 1
0
        protected void EnsureClientsInitialized(MockContext context)
        {
            if (!m_initialized)
            {
                lock (m_lock)
                {
                    if (!m_initialized)
                    {
                        m_ResourcesClient = ComputeManagementTestUtilities.GetResourceManagementClient(context, new RecordedDelegatingHandler {
                            StatusCodeToReturn = HttpStatusCode.OK
                        });
                        m_CrpClient = ComputeManagementTestUtilities.GetComputeManagementClient(context, new RecordedDelegatingHandler {
                            StatusCodeToReturn = HttpStatusCode.OK
                        });
                        m_SrpClient = ComputeManagementTestUtilities.GetStorageManagementClient(context, new RecordedDelegatingHandler {
                            StatusCodeToReturn = HttpStatusCode.OK
                        });
                        m_NrpClient = ComputeManagementTestUtilities.GetNetworkManagementClient(context, new RecordedDelegatingHandler {
                            StatusCodeToReturn = HttpStatusCode.OK
                        });

                        m_subId = m_CrpClient.SubscriptionId;
                        if (string.IsNullOrEmpty(Environment.GetEnvironmentVariable("AZURE_VM_TEST_LOCATION")))
                        {
                            m_location = ComputeManagementTestUtilities.DefaultLocation;
                        }
                        else
                        {
                            m_location = Environment.GetEnvironmentVariable("AZURE_VM_TEST_LOCATION").Replace(" ", "").ToLower();
                        }
                    }
                }
            }
        }
 protected void EnsureClientsInitialized(bool useSPN = false)
 {
     if (!m_initialized)
     {
         lock (m_lock)
         {
             if (!m_initialized)
             {
                 var handler = new RecordedDelegatingHandler {
                     StatusCodeToReturn = HttpStatusCode.OK
                 };
                 if (useSPN)
                 {
                     m_ResourcesClient = ComputeManagementTestUtilities.GetResourceManagementClientWithSpn(handler);
                     m_CrpClient       = ComputeManagementTestUtilities.GetComputeManagementClientWithSpn(handler);
                     m_SrpClient       = ComputeManagementTestUtilities.GetStorageManagementClientSpn(handler);
                     m_NrpClient       = ComputeManagementTestUtilities.GetNetworkResourceProviderClientSpn(handler);
                 }
                 else
                 {
                     m_ResourcesClient = ComputeManagementTestUtilities.GetResourceManagementClient(handler);
                     m_CrpClient       = ComputeManagementTestUtilities.GetComputeManagementClient(handler);
                     m_SrpClient       = ComputeManagementTestUtilities.GetStorageManagementClient(handler);
                     m_NrpClient       = ComputeManagementTestUtilities.GetNetworkResourceProviderClient(handler);
                 }
                 m_subId    = m_CrpClient.Credentials.SubscriptionId;
                 m_location = ComputeManagementTestUtilities.DefaultLocation;
             }
         }
     }
 }