public void UnregisterContainersTest()
        {
            using (UndoContext context = UndoContext.Current)
            {
                context.Start();

                string resourceNamespace = ConfigurationManager.AppSettings["ResourceNamespace"];

                var client = GetServiceClient<RecoveryServicesBackupManagementClient>(resourceNamespace);
                ContainerTestHelper containerTestHelper = new ContainerTestHelper(client);
                string mabContainerName = ConfigurationManager.AppSettings["MabContainerName"];
                AzureOperationResponse response = containerTestHelper.UnregisterMABContainer(mabContainerName);
            }               
        }
        public void UnregisterContainersTest()
        {
            using (UndoContext context = UndoContext.Current)
            {
                context.Start();

                string resourceNamespace = ConfigurationManager.AppSettings["ResourceNamespace"];

                var client = GetServiceClient<RecoveryServicesBackupManagementClient>(resourceNamespace);
                ContainerTestHelper containerTestHelper = new ContainerTestHelper(client);
                string sqlContainerName = ConfigurationManager.AppSettings["ContainerTypeAzureSql"] + ";" + ConfigurationManager.AppSettings["AzureSqlContainerName"];
                AzureOperationResponse response = containerTestHelper.UnregisterMABContainer(sqlContainerName);
                Assert.Equal(response.StatusCode, HttpStatusCode.NoContent);
            }
        }
        public void ListContainersTest()
        {
            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 containers
                ProtectionContainerListQueryParams queryParams = new ProtectionContainerListQueryParams();
                queryParams.BackupManagementType = CommonTestHelper.GetSetting(TestConstants.ProviderTypeAzureIaasVM);
                ContainerTestHelper containerTestHelper = new ContainerTestHelper(client);
                ProtectionContainerListResponse response = containerTestHelper.ListContainers(resourceGroupName, resourceName, queryParams);

                // VALIDATION: VM should be found in the list
                Assert.True(response.ItemList.ProtectionContainers.Any(
                    protectionContainer =>
                    {
                        return protectionContainer.Properties.GetType().IsSubclassOf(typeof(AzureIaaSVMProtectionContainer)) &&
                            protectionContainer.Name.Contains(containerUniqueName);
                    }),
                    "Retrieved list of containers doesn't contain AzureIaaSVMProtectionContainer test container");
            }
        }
        public void ListContainersTest()
        {
            using (UndoContext context = UndoContext.Current)
            {
                context.Start();

                string resourceNamespace = ConfigurationManager.AppSettings["ResourceNamespace"];

                var client = GetServiceClient<RecoveryServicesBackupManagementClient>(resourceNamespace);
                ProtectionContainerListQueryParams queryParams = new ProtectionContainerListQueryParams();
                queryParams.BackupManagementType = BackupManagementType.MAB.ToString();

                ContainerTestHelper containerTestHelper = new ContainerTestHelper(client);
                ProtectionContainerListResponse response = containerTestHelper.ListMABContainers(queryParams);

                string containerUniqueName = CommonTestHelper.GetSetting(TestConstants.RsVaultMabContainerUniqueName);
                MabProtectionContainer container = response.ItemList.ProtectionContainers[0].Properties as MabProtectionContainer;
                Assert.NotNull(container);
                Assert.Equal(containerUniqueName, container.FriendlyName);
            }
        }
        public void ListContainersTest()
        {
            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);
                ProtectionContainerListQueryParams queryParams = new ProtectionContainerListQueryParams();
                queryParams.BackupManagementType = BackupManagementType.AzureSql.ToString();

                ContainerTestHelper containerTestHelper = new ContainerTestHelper(client);
                ProtectionContainerListResponse response = containerTestHelper.ListContainers(rsVaultRgName, rsVaultName, queryParams);

                string containerUniqueName = ConfigurationManager.AppSettings["ContainerTypeAzureSql"] + ";" + ConfigurationManager.AppSettings["AzureSqlContainerName"];
                var container = response.ItemList.ProtectionContainers[0];
                Assert.NotNull(container);
                Assert.Equal(containerUniqueName, container.Name);
            }
        }
        public void RefreshContainerTest()
        {
            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"];
                string fabricName = ConfigurationManager.AppSettings["AzureBackupFabricName"];

                var client = GetServiceClient<RecoveryServicesBackupManagementClient>(resourceNamespace);

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

                // ACTION: Trigger refresh containers
                ContainerTestHelper containerTestHelper = new ContainerTestHelper(client);
                var response = containerTestHelper.RefreshContainer(resourceGroupName, resourceName, fabricName);
            }
        }