Пример #1
0
        public void ListRecoveryServicesProtectionPolicyTest()
        {
            using (UndoContext context = UndoContext.Current)
            {
                context.Start();

                string resourceNamespace = ConfigurationManager.AppSettings["ResourceNamespace"];
                var client = GetServiceClient<RecoveryServicesBackupManagementClient>(resourceNamespace);
                PolicyTestHelper policyTestHelper = new PolicyTestHelper(client);
                ProtectionPolicyQueryParameters queryParams = new ProtectionPolicyQueryParameters();

                ProtectionPolicyListResponse response = policyTestHelper.ListProtectionPolicy(queryParams);

                // atleast one default policy is expected
                Assert.NotNull(response.ItemList);
                Assert.NotNull(response.ItemList.Value);

                IList<ProtectionPolicyResource> policyList = response.ItemList.Value;

                // atleast one default policy should be there
                Assert.NotEmpty(policyList);

                foreach (ProtectionPolicyResource resource in policyList)
                {
                    Assert.NotNull(resource.Id);
                    Assert.NotNull(resource.Name);
                    Assert.NotNull(resource.Type);
                    Assert.NotNull(resource.Properties);
                }
            }
        }       
Пример #2
0
        public void GetAddUpdateDeleteIaaSVMPolicyTest()
        {
            using (UndoContext context = UndoContext.Current)
            {
                context.Start();

                string resourceNamespace = ConfigurationManager.AppSettings["ResourceNamespace"];
                var client = GetServiceClient<RecoveryServicesBackupManagementClient>(resourceNamespace);
                PolicyTestHelper policyTestHelper = new PolicyTestHelper(client);
                string policyName = ConfigurationManager.AppSettings["IaaSVMPolicyName"];

                // get policy
                ProtectionPolicyResponse response = policyTestHelper.GetProtectionPolicy(policyName);
                Assert.NotNull(response.Item.Name);
                Assert.Equal(response.Item.Name, policyName);
                Assert.NotNull(response.Item.Id);
                Assert.NotNull(response.Item.Type);
                Assert.NotNull(response.Item.Properties);

                // now add new policy
                ProtectionPolicyRequest request = new ProtectionPolicyRequest()
                {
                    Item = new ProtectionPolicyResource()
                    {
                        Properties = response.Item.Properties
                    }
                };

                string newPolicyName = ConfigurationManager.AppSettings["IaaSVMModifiedPolicyName"];
                response = policyTestHelper.AddOrUpdateProtectionPolicy(
                                                       newPolicyName,
                                                       request);
                // now update the policy
                response = policyTestHelper.AddOrUpdateProtectionPolicy(
                                                       newPolicyName,
                                                       request);
                // validations
                Assert.NotNull(response.Item.Name);
                Assert.Equal(response.Item.Name, newPolicyName);
                Assert.NotNull(response.Item.Id);
                Assert.NotNull(response.Item.Type);
                Assert.NotNull(response.Item.Properties);


                // delete the policy
                AzureOperationResponse deleteResponse = policyTestHelper.DeleteProtectionPolicy(newPolicyName);
                Assert.Equal(deleteResponse.StatusCode, HttpStatusCode.OK);
            }
        }