コード例 #1
0
        public void TestDisassociateReserveIP()
        {
            using (var undoContext = AZT.UndoContext.Current)
            {
                undoContext.Start();
                using (NetworkTestBase _testFixture = new NetworkTestBase())
                {
                    ComputeManagementClient computeClient = _testFixture.GetComputeManagementClient();
                    StorageManagementClient storageClient = _testFixture.GetStorageManagementClient();
                    var  managementClient      = _testFixture.ManagementClient;
                    bool storageAccountCreated = false;
                    bool hostedServiceCreated  = false;
                    bool reserveIpCreated      = false;

                    string       storageAccountName = HttpMockServer.GetAssetName("teststorage1234", "teststorage").ToLower();
                    string       serviceName        = AZT.TestUtilities.GenerateName("testsvc");
                    string       deploymentName     = string.Format("{0}Prod", serviceName);
                    string       reserveIpName      = HttpMockServer.GetAssetName("rip", "testrip").ToLower();
                    string       location           = managementClient.GetDefaultLocation("Storage", "Compute");
                    const string usWestLocStr       = "West US";
                    try
                    {
                        _testFixture.AssociateReservedIP(
                            usWestLocStr,
                            location,
                            storageAccountName,
                            ref storageAccountCreated,
                            serviceName,
                            deploymentName,
                            reserveIpName,
                            ref hostedServiceCreated,
                            ref reserveIpCreated);

                        Assert.True(storageAccountCreated);
                        Assert.True(hostedServiceCreated);
                        Assert.True(reserveIpCreated);
                        DisassociateReservedIP(_testFixture, reserveIpName, serviceName, deploymentName);
                    }
                    catch (Exception)
                    {
                        throw;
                    }
                    finally
                    {
                        if (storageAccountCreated)
                        {
                            storageClient.StorageAccounts.Delete(storageAccountName);
                        }
                        if (hostedServiceCreated)
                        {
                            computeClient.HostedServices.DeleteAll(serviceName);
                        }
                        if (reserveIpCreated)
                        {
                            _testFixture.NetworkClient.ReservedIPs.Delete(reserveIpName);
                        }
                    }
                }
            }
        }
コード例 #2
0
        public void TestDisassociateReserveIP()
        {
            using (var undoContext = AZT.UndoContext.Current)
            {
                undoContext.Start();
                using (NetworkTestBase _testFixture = new NetworkTestBase())
                {
                    ComputeManagementClient computeClient = _testFixture.GetComputeManagementClient();
                    StorageManagementClient storageClient = _testFixture.GetStorageManagementClient();
                    var managementClient = _testFixture.ManagementClient;
                    bool storageAccountCreated = false;
                    bool hostedServiceCreated = false;
                    bool reserveIpCreated = false;

                    string storageAccountName = HttpMockServer.GetAssetName("teststorage1234", "teststorage").ToLower();
                    string serviceName = AZT.TestUtilities.GenerateName("testsvc");
                    string deploymentName = string.Format("{0}Prod", serviceName);
                    string reserveIpName = HttpMockServer.GetAssetName("rip", "testrip").ToLower();
                    string location = managementClient.GetDefaultLocation("Storage", "Compute");
                    const string usWestLocStr = "West US";
                    try
                    {
                        _testFixture.AssociateReservedIP(
                            usWestLocStr,
                            location,
                            storageAccountName,
                            ref storageAccountCreated,
                            serviceName,
                            deploymentName,
                            reserveIpName,
                            ref hostedServiceCreated,
                            ref reserveIpCreated);

                        Assert.True(storageAccountCreated);
                        Assert.True(hostedServiceCreated);
                        Assert.True(reserveIpCreated);
                        DisassociateReservedIP(_testFixture, reserveIpName, serviceName, deploymentName);

                    }
                    catch (Exception)
                    {
                        throw;
                    }
                    finally
                    {
                        if (storageAccountCreated)
                        {
                            storageClient.StorageAccounts.Delete(storageAccountName);
                        }
                        if (hostedServiceCreated)
                        {
                            computeClient.HostedServices.DeleteAll(serviceName);
                        }
                        if (reserveIpCreated)
                        {
                            _testFixture.NetworkClient.ReservedIPs.Delete(reserveIpName);
                        }
                    }
                }
            }
        }