public void ListProtectedItemTest()
        {
            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);

                ProtectedItemListQueryParam queryParams = new ProtectedItemListQueryParam();
                queryParams.BackupManagementType = CommonTestHelper.GetSetting(TestConstants.ProviderTypeAzureSql);
                queryParams.DatasourceType       = CommonTestHelper.GetSetting(TestConstants.WorkloadTypeAzureSqlDb);

                ProtectedItemTestHelpers itemTestHelper = new ProtectedItemTestHelpers(client);
                var response = itemTestHelper.ListProtectedItems(rsVaultRgName, rsVaultName, queryParams);

                string itemName = ConfigurationManager.AppSettings[TestConstants.AzureSqlItemName];
                Assert.True(response.ItemList.Value.Any(item =>
                {
                    return((item.Properties is AzureSqlProtectedItem) &&
                           item.Name.Contains(itemName));
                }),
                            "Retrieved list of items doesn't contain AzureSqlProtectedItem test item");
            }
        }
        public void ListProtectedItemsTest()
        {
            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"];
                // TODO: Create VM instead of taking these parameters from config
                string containerUniqueName = ConfigurationManager.AppSettings["RsVaultIaasVMContainerUniqueNameRP"];
                string itemUniqueName      = ConfigurationManager.AppSettings["RsVaultIaasVMItemUniqueNameRP"];
                string containeType        = ConfigurationManager.AppSettings["IaaSVMContainerType"];
                string itemType            = ConfigurationManager.AppSettings["IaaSVMItemType"];
                string containerUri        = containeType + ";" + containerUniqueName;
                string itemUri             = itemType + ";" + itemUniqueName;

                var client = GetServiceClient <RecoveryServicesBackupManagementClient>(resourceNamespace);

                // 1. Create vault
                VaultTestHelpers vaultTestHelper = new VaultTestHelpers(client);
                vaultTestHelper.CreateVault(resourceGroupName, resourceName, location);

                // 2. Get default policy
                PolicyTestHelpers policyTestHelper = new PolicyTestHelpers(client);
                string            policyId         = policyTestHelper.GetDefaultPolicyId(resourceGroupName, resourceName);

                // 3. Enable protection
                ProtectedItemTestHelpers protectedItemTestHelper = new ProtectedItemTestHelpers(client);
                protectedItemTestHelper.EnableProtection(resourceGroupName, resourceName, policyId, containerUri, itemUri);

                // ACTION: List protected items
                ProtectedItemListQueryParam queryParams = new ProtectedItemListQueryParam();
                queryParams.BackupManagementType = CommonTestHelper.GetSetting(TestConstants.ProviderTypeAzureIaasVM);
                queryParams.DatasourceType       = CommonTestHelper.GetSetting(TestConstants.WorkloadTypeVM);
                var response = protectedItemTestHelper.ListProtectedItems(resourceGroupName, resourceName, queryParams);

                // VALIDATION: VM should be found in the list
                Assert.True(response.ItemList.Value.Any(item =>
                {
                    return(item.Properties.GetType().IsSubclassOf(typeof(AzureIaaSVMProtectedItem)) &&
                           item.Name.Contains(itemUniqueName));
                }),
                            "Retrieved list of items doesn't contain AzureIaaSVMProtectedItem test item");
            }
        }