/// <summary>
        /// Triggers clone operation on a fileserver using a given backup
        /// </summary>
        /// <param name="backupSet"></param>
        /// <param name="deviceName"></param>
        /// <param name="fileServer"></param>
        /// <param name="backupElementName"></param>
        /// <param name="restoredShareName"></param>
        public static void Clone(
            this Backup backupSet,
            string deviceName,
            FileServer fileServer,
            string backupElementName,
            string restoredShareName)
        {
            var device = backupSet.Client.Devices.Get(
                deviceName,
                backupSet.ResourceGroupName,
                backupSet.ManagerName);

            Assert.True(
                device != null,
                "no matching device found with name:" + deviceName);

            Assert.True(
                fileServer != null,
                "FileServer param is null");

            var restoreFileShare = new FileShare(
                backupSet.Client,
                backupSet.ResourceGroupName,
                backupSet.ManagerName,
                TestConstants.DefaultTieredFileShareName);

            restoreFileShare.Initialize(DataPolicy.Tiered);
            restoreFileShare.Description = "Restore file Share";
            restoreFileShare.AdminUser   = deviceName + "\\StorSimpleAdmin";

            CloneRequest cloneRequest = new CloneRequest()
            {
                NewEndpointName     = restoredShareName,
                TargetAccessPointId = fileServer.Id,
                TargetDeviceId      = device.Id,
                Share = restoreFileShare
            };

            backupSet.Client.Backups.Clone(
                device.Name.GetDoubleEncoded(),
                backupSet.Name.GetDoubleEncoded(),
                backupElementName,
                cloneRequest,
                backupSet.ResourceGroupName,
                backupSet.ManagerName);
        }
        /// <summary>
        /// Returns fileshares of a given fileserver
        /// </summary>
        /// <param name="fileServer"></param>
        /// <param name="deviceName"></param>
        /// <returns></returns>
        public static IEnumerable <FileShare> GetFileShares(
            this FileServer fileServer,
            string deviceName)
        {
            var fileShares = fileServer.Client.FileShares.ListByFileServer(
                deviceName.GetDoubleEncoded(),
                fileServer.Name.GetDoubleEncoded(),
                fileServer.ResourceGroupName,
                fileServer.ManagerName);

            if (fileShares != null && !fileShares.Any())
            {
                // Create a FileShare with Tiered data policy
                var fileShareToCreate = new FileShare(
                    fileServer.Client,
                    fileServer.ResourceGroupName,
                    fileServer.ManagerName,
                    TestConstants.DefaultTieredFileShareName);
                fileShareToCreate.Initialize(DataPolicy.Tiered);

                fileShareToCreate.CreateOrUpdate(
                    fileServer.Name,
                    fileServer.Name);
            }

            // Return from the list
            fileShares = fileServer.Client.FileShares.ListByFileServer(
                deviceName.GetDoubleEncoded(),
                fileServer.Name.GetDoubleEncoded(),
                fileServer.ResourceGroupName,
                fileServer.ManagerName);

            if (fileShares != null)
            {
                foreach (var fileShare in fileShares)
                {
                    fileShare.SetBaseResourceValues(
                        fileServer.Client,
                        fileServer.ResourceGroupName,
                        fileServer.ManagerName);
                }
            }

            return(fileShares);
        }
        public void TestCreateOrUpdateFileShare()
        {
            try
            {
                var fileServers = TestUtilities.GetFileServers(
                    this.Client,
                    this.ResourceGroupName,
                    this.ManagerName);

                Assert.True(
                    fileServers != null && fileServers.Any(),
                    $"No fileservers were found in the manger {this.ManagerName}");

                // Select the first fileserver
                var fileServer = fileServers.First();

                // Create a FileShare with Tiered data policy
                var fileShare = new FileShare(
                    this.Client,
                    this.ResourceGroupName,
                    this.ManagerName,
                    "Auto-TestFileShare1");
                fileShare.Initialize(DataPolicy.Tiered);

                var fileShareCreated = fileShare.CreateOrUpdate(
                    fileServer.Name,
                    fileServer.Name);

                // Create a FileShare with Local data policy
                var fileShare2 = new FileShare(
                    this.Client,
                    this.ResourceGroupName,
                    this.ManagerName,
                    "Auto-TestFileShare2");
                fileShare2.Initialize(DataPolicy.Local);

                var fileShareCreated2 = fileShare2.CreateOrUpdate(
                    fileServer.Name,
                    fileServer.Name);

                // Update Description and ShareStatus
                fileShareCreated.Description = "Updated: " + fileShareCreated.Description;
                fileShareCreated.ShareStatus = ShareStatus.Offline;
                fileShareCreated             = fileShareCreated.CreateOrUpdate(
                    fileServer.Name,
                    fileServer.Name);

                // Validate FileShares by Managers
                var fileSharesByFileServer = this.Client.FileShares.ListByFileServer(
                    fileServer.Name,
                    fileServer.Name,
                    this.ResourceGroupName,
                    this.ManagerName);

                var fileSharesByDevice = this.Client.FileShares.ListByDevice(
                    fileServer.Name,
                    this.ResourceGroupName,
                    this.ManagerName);
            }
            catch (Exception e)
            {
                Assert.Null(e);
            }
            #endregion Test methods
        }