private void Initialize(MockContext context)
        {
            handler = new RecordedDelegatingHandler {
                StatusCodeToReturn = HttpStatusCode.OK
            };
            resourcesClient = ComputeManagementTestUtilities.GetResourceManagementClient(context, handler);
            computeClient   = ComputeManagementTestUtilities.GetComputeManagementClient(context, handler);

            subId    = computeClient.SubscriptionId;
            location = m_location;

            baseResourceGroupName = ComputeManagementTestUtilities.GenerateName(TestPrefix);
            resourceGroup1Name    = baseResourceGroupName + "_1";

            resourceGroup1 = resourcesClient.ResourceGroups.CreateOrUpdate(
                resourceGroup1Name,
                new ResourceGroup
            {
                Location = location,
                Tags     = new Dictionary <string, string>()
                {
                    { resourceGroup1Name, DateTime.UtcNow.ToString("u") }
                }
            });
        }
Beispiel #2
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;
             }
         }
     }
 }
Beispiel #4
0
        private void Initialize()
        {
            handler = new RecordedDelegatingHandler {
                StatusCodeToReturn = HttpStatusCode.OK
            };
            resourcesClient = ComputeManagementTestUtilities.GetResourceManagementClient(handler);
            computeClient   = ComputeManagementTestUtilities.GetComputeManagementClient(handler);

            subId    = computeClient.Credentials.SubscriptionId;
            location = ComputeManagementTestUtilities.DefaultLocation;

            resourceGroupName = TestUtilities.GenerateName(testPrefix);

            resourceGroup = resourcesClient.ResourceGroups.CreateOrUpdate(
                resourceGroupName,
                new ResourceGroup
            {
                Location = location
            });
        }