public void ListProtectionPolicyTest() { using (UndoContext context = UndoContext.Current) { context.Start(); string resourceNamespace = ConfigurationManager.AppSettings["ResourceNamespace"]; string resourceGroupName = ConfigurationManager.AppSettings["RsVaultRgNameRP"]; string resourceName = ConfigurationManager.AppSettings["RsVaultNameRP"]; string location = ConfigurationManager.AppSettings["vaultLocationRP"]; var client = GetServiceClient<RecoveryServicesBackupManagementClient>(resourceNamespace); // 1. Create vault VaultTestHelpers vaultTestHelper = new VaultTestHelpers(client); vaultTestHelper.CreateVault(resourceGroupName, resourceName, location); // ACTION: List policies PolicyTestHelpers policyTestHelper = new PolicyTestHelpers(client); ProtectionPolicyQueryParameters queryParams = new ProtectionPolicyQueryParameters(); ProtectionPolicyListResponse response = policyTestHelper.ListProtectionPolicy(resourceGroupName, resourceName, queryParams); // VALIDATION: At least default policy is expected Assert.NotNull(response.ItemList); Assert.NotNull(response.ItemList.Value); Assert.NotEmpty(response.ItemList.Value); foreach (ProtectionPolicyResource resource in response.ItemList.Value) { Assert.NotNull(resource.Id); Assert.NotNull(resource.Name); Assert.NotNull(resource.Type); Assert.NotNull(resource.Properties); } } }
public void ListProtectionPolicyTest() { using (UndoContext context = UndoContext.Current) { context.Start(); string resourceNamespace = ConfigurationManager.AppSettings["ResourceNamespace"]; string rsVaultRgName = CommonTestHelper.GetSetting(TestConstants.RsVaultRgName); string rsVaultName = CommonTestHelper.GetSetting(TestConstants.RsVaultName); var client = GetServiceClient<RecoveryServicesBackupManagementClient>(resourceNamespace); PolicyTestHelpers policyTestHelper = new PolicyTestHelpers(client); ProtectionPolicyQueryParameters queryParams = new ProtectionPolicyQueryParameters(); queryParams.BackupManagementType = ConfigurationManager.AppSettings["ProviderTypeAzureSql"]; ProtectionPolicyListResponse response = policyTestHelper.ListProtectionPolicy(rsVaultRgName, rsVaultName, 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); } } }