public void PipelineMultipleShareNamesToRemoveTest()
        {
            // TODO: Generate more random names for file shares after the
            // naming rules is settled down.
            int numberOfShares = this.randomProvider.Next(2, 33);

            string[] names = Enumerable.Range(0, numberOfShares)
                             .Select(i => CloudFileUtil.GenerateUniqueFileShareName()).ToArray();
            foreach (var name in names)
            {
                fileUtil.EnsureFileShareExists(name);
            }

            try
            {
                CommandAgent.RemoveFileShareFromPipeline();
                var result = CommandAgent.Invoke(names);

                CommandAgent.AssertNoError();
                result.AssertNoResult();
            }
            finally
            {
                foreach (string fileShareName in names)
                {
                    fileUtil.DeleteFileShareIfExists(fileShareName);
                }
            }
        }
示例#2
0
        public void DownloadBatchFilesFromListingResult()
        {
            int numberOfFilesToDownload = this.randomProvider.Next(5, 20);
            List <CloudFile> files      = new List <CloudFile>();
            List <string>    fileNames  = new List <string>();

            for (int i = 0; i < numberOfFilesToDownload; i++)
            {
                string cloudFileName = CloudFileUtil.GenerateUniqueFileName();
                string localFilePath = Path.Combine(Test.Data.Get("TempDir"), CloudFileUtil.GenerateUniqueFileName());
                FileUtil.GenerateSmallFile(localFilePath, Utility.GetRandomTestCount(5, 10), true);
                files.Add(fileUtil.CreateFile(this.fileShare, cloudFileName, localFilePath));
                File.Delete(localFilePath);
                fileNames.Add(cloudFileName.ToLowerInvariant());
            }

            DirectoryInfo localDir = new DirectoryInfo(Test.Data.Get("TempDir"));

            CommandAgent.GetFile(this.fileShare);
            ((PowerShellAgent)CommandAgent).PowerShellSession.AddCommand("Get-AzureStorageFileContent");
            ((PowerShellAgent)CommandAgent).PowerShellSession.AddParameter("Destination", localDir.FullName);
            CommandAgent.Invoke();
            CommandAgent.AssertNoError();

            var localFilesInfo = localDir.GetFiles();

            foreach (var fileInfo in localFilesInfo)
            {
                fileNames.Remove(fileInfo.Name.ToLowerInvariant());
            }

            Test.Assert(fileNames.Count == 0, "All files should be downloaded while missing: {0}", string.Join(",", fileNames));
        }
        public void GetFileShareUsageTest()
        {
            string fileShareName = CloudFileUtil.GenerateUniqueFileShareName();
            string cloudFileName = CloudFileUtil.GenerateUniqueFileName();
            var    fileShare     = fileUtil.EnsureFileShareExists(fileShareName);

            try
            {
                CommandAgent.GetFileShareByName(fileShareName);

                var result = CommandAgent.Invoke();

                CommandAgent.AssertNoError();
                result.AssertObjectCollection(obj => result.AssertCloudFileContainer(obj, fileShareName), 1);

                fileUtil.CreateFile(fileShare.GetRootDirectoryReference(), cloudFileName);

                CommandAgent.Clear();
                CommandAgent.GetFileShareByName(fileShareName);

                result = CommandAgent.Invoke();
                CommandAgent.AssertNoError();
                result.AssertObjectCollection(obj => result.AssertCloudFileContainer(obj, fileShareName, 1), 1);
            }
            finally
            {
                fileUtil.DeleteFileShareIfExists(fileShareName);
            }
        }
        public void GetDirsToListDir()
        {
            fileUtil.CleanupDirectory(this.fileShare.GetRootDirectoryReference());
            var dirNames = Enumerable.Range(0, this.randomProvider.Next(5, 20)).Select(x => CloudFileUtil.GenerateUniqueFileName()).ToList();

            fileUtil.CleanupDirectory(this.fileShare.GetRootDirectoryReference());
            var dirs      = dirNames.Select(name => fileUtil.EnsureDirectoryExists(this.fileShare, name)).ToList();
            var fileNames = Enumerable.Range(0, this.randomProvider.Next(5, 20)).Select(x => CloudFileUtil.GenerateUniqueFileName()).ToList();
            var files     = fileNames.Select(name => fileUtil.CreateFile(dirs[0], name)).ToList();

            CommandAgent.GetFile(this.fileShare, dirNames[0]);
            ((PowerShellAgent)CommandAgent).PowerShellSession.AddCommand("Get-AzureStorageFile");
            var result = CommandAgent.Invoke();

            CommandAgent.AssertNoError();
            result.AssertFileListItems(files, Enumerable.Empty <CloudFileDirectory>());

            foreach (var dir in dirs)
            {
                fileNames = Enumerable.Range(0, this.randomProvider.Next(5, 20)).Select(x => CloudFileUtil.GenerateUniqueFileName()).ToList();
                files.AddRange(fileNames.Select(name => fileUtil.CreateFile(dir, name)).ToList());
            }

            CommandAgent.Clear();
            CommandAgent.GetFile(this.fileShare);
            ((PowerShellAgent)CommandAgent).PowerShellSession.AddCommand("Get-AzureStorageFile");
            result = CommandAgent.Invoke();
            CommandAgent.AssertNoError();
            result.AssertFileListItems(files, Enumerable.Empty <CloudFileDirectory>());
            fileUtil.CleanupDirectory(this.fileShare.GetRootDirectoryReference());
        }
示例#5
0
        /// <summary>
        /// Positive functional test case 5.8.1
        /// </summary>
        /// <remarks>
        /// RDTask 1414230:
        /// Test case DownloadExistingFile requires a 200G file already exist
        /// on the storage account in the file service. It does not make sense
        /// to generate a 200G file at runtime, upload it and download it in
        /// functional test cases.
        /// Currently, since the only test we could do is against dev fabric,
        /// we could not prepare such file on the cloud first. So the test case
        /// is temp blocked.
        /// Once the xSMB file service GAed, and we are testing against real
        /// storage accounts, we could put this case back online.
        /// </remarks>
        ////[TestMethod]
        ////[TestCategory(PsTag.File)]
        public void DownloadExistingFileTest()
        {
            string[] filesToDownload = Test.Data.Get("ExistingFilesToDownload").Split(';');
            string[] md5Checksum     = Test.Data.Get("ExistingFilesMD5").Split(';');

            for (int i = 0; i < filesToDownload.Length; i++)
            {
                var destination = Path.Combine(Test.Data.Get("TempDir"), FileUtil.GetSpecialFileName());
                try
                {
                    Test.Info("About to download: {0} to {1}", filesToDownload[i], destination);
                    CommandAgent.DownloadFile(this.fileShare, filesToDownload[i], destination);
                    var result = CommandAgent.Invoke();
                    CommandAgent.AssertNoError();
                    result.AssertNoResult();

                    string destinationMD5 = FileUtil.GetFileContentMD5(destination);
                    Test.Assert(
                        destinationMD5.Equals(md5Checksum[i], StringComparison.Ordinal),
                        "MD5 checksum of the downloaded file mismatches. Expected: {0}, Actural: {1}.",
                        md5Checksum[i],
                        destinationMD5);
                }
                finally
                {
                    FileUtil.RemoveFile(destination);
                }
            }
        }
示例#6
0
 public void CreateShareWith3CharactersTest()
 {
     this.CreateShareInternal(
         () => FileNamingGenerator.GenerateValidShareName(3),
         (results, shareName) =>
     {
         CommandAgent.AssertNoError();
         results.AssertObjectCollection(obj => results.AssertCloudFileContainer(obj, shareName));
     });
 }
示例#7
0
        public void CreateDirectoryAndListThroughPSHTest()
        {
            string directoryName = CloudFileUtil.GenerateUniqueDirectoryName();

            this.mountedShareRoot.CreateSubdirectory(directoryName);
            CommandAgent.GetFile(this.fileShare);
            var result = CommandAgent.Invoke();

            CommandAgent.AssertNoError();
            result.AssertObjectCollection(obj => obj.AssertCloudFileDirectory(directoryName));
        }
示例#8
0
        public void CreateDirectoryAndListThroughSMBTest()
        {
            string directoryName = CloudFileUtil.GenerateUniqueDirectoryName();

            CommandAgent.NewDirectory(this.fileShare, directoryName);
            CommandAgent.Invoke();
            CommandAgent.AssertNoError();
            SMBValidationRetry(
                () => this.mountedShareRoot.GetDirectories().Select(x => x.Name).Contains(directoryName),
                "list the newly created directory through SMB protocol");
        }
示例#9
0
        public void UploadWithPassThru()
        {
            string cloudFileName = CloudFileUtil.GenerateUniqueFileName();
            string localFilePath = Path.Combine(Test.Data.Get("TempDir"), CloudFileUtil.GenerateUniqueFileName());

            FileUtil.GenerateSmallFile(localFilePath, Utility.GetRandomTestCount(5, 10), true);
            CommandAgent.UploadFile(this.fileShare, localFilePath, cloudFileName, false, true);
            var result = CommandAgent.Invoke();

            CommandAgent.AssertNoError();
            result.AssertObjectCollection(obj => obj.AssertCloudFile(cloudFileName));
        }
示例#10
0
        public void GetFilesFromEmptyFolderTest()
        {
            var dir = this.fileShare.GetRootDirectoryReference();

            fileUtil.CleanupDirectory(dir);

            CommandAgent.GetFile(this.fileShare);
            var result = CommandAgent.Invoke();

            CommandAgent.AssertNoError();
            result.AssertFileListItems(Enumerable.Empty <CloudFile>(), Enumerable.Empty <CloudFileDirectory>());
        }
        private void CreateDirectoryInternal(Action newDirectoryAction, string dirName, bool assertForSuccess = true, bool traceCommand = true)
        {
            newDirectoryAction();
            var result = CommandAgent.Invoke(traceCommand: traceCommand);

            if (assertForSuccess)
            {
                CommandAgent.AssertNoError();
                result.AssertObjectCollection(obj => result.AssertCloudFileDirectory(obj, dirName), 1);
                fileUtil.AssertDirectoryExists(this.fileShare, dirName.Trim(CloudFileUtil.PathSeparators), "Directory should exist after creation.");
            }
        }
        public void RemoveFileFromRelativePathWhereIntermediatePathMightNotExistTest()
        {
            var    baseDir           = fileUtil.EnsureFolderStructure(this.fileShare, "a/b/c");
            string cloudFileName     = CloudFileUtil.GenerateUniqueFileName();
            string relativeCloudPath = "../../ddd/../b/./c/" + cloudFileName;

            fileUtil.CreateFile(baseDir, cloudFileName);
            CommandAgent.RemoveFile(baseDir, relativeCloudPath);
            CommandAgent.Invoke();
            CommandAgent.AssertNoError();
            Test.Assert(!baseDir.GetFileReference(cloudFileName).Exists(), "File should exist after uploaded.");
        }
        public void RemoveUsingPath()
        {
            var    baseDir       = fileUtil.EnsureFolderStructure(this.fileShare, "a/b/c");
            string cloudFileName = CloudFileUtil.GenerateUniqueFileName();
            string cloudPath     = "/a/b/c/" + cloudFileName;
            var    sourceFile    = fileUtil.CreateFile(this.fileShare, cloudPath);

            CommandAgent.RemoveFile(this.fileShare, cloudPath);
            CommandAgent.Invoke();
            CommandAgent.AssertNoError();
            Test.Assert(!sourceFile.Exists(), "File should not exist after removed.");
        }
示例#14
0
        public void UploadFileFromRelativePathWhereIntermediatePathMightNotExistTest()
        {
            var    baseDir           = fileUtil.EnsureFolderStructure(this.fileShare, "a/b/c");
            string cloudFileName     = CloudFileUtil.GenerateUniqueFileName();
            string relativeCloudPath = "../../ddd/../b/./c/" + cloudFileName;
            string localFilePath     = Path.Combine(Test.Data.Get("TempDir"), CloudFileUtil.GenerateUniqueFileName());

            FileUtil.GenerateSmallFile(localFilePath, Utility.GetRandomTestCount(5, 10), true);
            CommandAgent.UploadFile(baseDir, localFilePath, relativeCloudPath);
            CommandAgent.Invoke();
            CommandAgent.AssertNoError();
            Test.Assert(baseDir.GetFileReference(cloudFileName).Exists(), "File should exist after uploaded.");
        }
示例#15
0
        public void CreateFileAndListThroughSMBTest()
        {
            string fileName      = CloudFileUtil.GenerateUniqueFileName();
            string localFilePath = Path.Combine(Test.Data.Get("TempDir"), CloudFileUtil.GenerateUniqueFileName());

            FileUtil.GenerateSmallFile(localFilePath, Utility.GetRandomTestCount(5, 10), true);
            CommandAgent.UploadFile(this.fileShare, localFilePath, fileName);
            CommandAgent.Invoke();
            CommandAgent.AssertNoError();
            SMBValidationRetry(
                () => this.mountedShareRoot.GetFiles().Select(x => x.Name).Contains(fileName),
                "list the newly created directory through SMB protocol");
        }
        public void RemoveFileUnderADirectory()
        {
            string cloudFileName      = CloudFileUtil.GenerateUniqueFileName();
            string cloudDirectoryName = CloudFileUtil.GenerateUniqueDirectoryName();
            var    directory          = fileUtil.EnsureDirectoryExists(this.fileShare, cloudDirectoryName);
            var    file = fileUtil.CreateFile(directory, cloudFileName);

            CommandAgent.RemoveFile(file);
            var result = CommandAgent.Invoke();

            CommandAgent.AssertNoError();
            result.AssertNoResult();
            fileUtil.AssertFileNotExists(this.fileShare, file.Name, "File should not exist after deleting.");
        }
示例#17
0
        public void UploadToCloudDirectory()
        {
            string cloudFileName      = CloudFileUtil.GenerateUniqueFileName();
            string cloudDirectoryName = CloudFileUtil.GenerateUniqueDirectoryName();
            var    directory          = fileUtil.EnsureDirectoryExists(this.fileShare, cloudDirectoryName);
            string localFilePath      = Path.Combine(Test.Data.Get("TempDir"), CloudFileUtil.GenerateUniqueFileName());

            FileUtil.GenerateSmallFile(localFilePath, Utility.GetRandomTestCount(5, 10), true);
            CommandAgent.UploadFile(directory, localFilePath, cloudFileName, true);
            var result = CommandAgent.Invoke();

            CommandAgent.AssertNoError();
            result.AssertNoResult();
        }
        private IExecutionResult RemoveDirectoryInternal(Action removeDirectoryAction, CloudFileDirectory dirToBeRemovedForValidation = null)
        {
            removeDirectoryAction();
            var result = CommandAgent.Invoke();

            if (dirToBeRemovedForValidation != null)
            {
                CommandAgent.AssertNoError();
                result.AssertNoResult();
                Test.Assert(!dirToBeRemovedForValidation.Exists(), "Directory should not exist after removed.");
            }

            return(result);
        }
示例#19
0
        public void GetFilesFromDirectoryTest()
        {
            var fileNames     = Enumerable.Range(0, this.randomProvider.Next(5, 20)).Select(x => CloudFileUtil.GenerateUniqueFileName()).ToList();
            var directoryName = CloudFileUtil.GenerateUniqueDirectoryName();
            var dir           = fileUtil.EnsureDirectoryExists(this.fileShare, directoryName);

            fileUtil.CleanupDirectory(dir);
            var files = fileNames.Select(name => fileUtil.CreateFile(dir, name)).ToList();

            CommandAgent.GetFile(dir);
            var result = CommandAgent.Invoke();

            CommandAgent.AssertNoError();
            result.AssertFileListItems(files, Enumerable.Empty <CloudFileDirectory>());
        }
        public void PipelineMultipleDirectoryNamesTest()
        {
            // TODO: Generate more random names for file shares after the
            // naming rules is settled down.
            int numberOfDirectories = this.randomProvider.Next(2, 33);

            string[] names = Enumerable.Range(0, numberOfDirectories)
                             .Select(i => CloudFileUtil.GenerateUniqueDirectoryName()).ToArray();

            CommandAgent.NewDirectoryFromPipeline(this.fileShare.Name);
            var result = CommandAgent.Invoke(names);

            CommandAgent.AssertNoError();
            result.AssertObjectCollection(obj => obj.AssertCloudFileDirectory(new List <string>(names)), numberOfDirectories);
        }
        public void CreateDirectoryPipeline()
        {
            string dir1            = CloudFileUtil.GenerateUniqueDirectoryName();
            string dir2            = CloudFileUtil.GenerateUniqueDirectoryName();
            string fullPathForDir2 = string.Concat(dir1, "/", dir2);

            CommandAgent.NewDirectory(this.fileShare, dir1);
            ((PowerShellAgent)CommandAgent).PowerShellSession.AddCommand("New-AzureStorageDirectory");
            ((PowerShellAgent)CommandAgent).PowerShellSession.AddParameter("Path", dir2);
            var result = CommandAgent.Invoke();

            CommandAgent.AssertNoError();
            result.AssertObjectCollection(obj => obj.AssertCloudFileDirectory(fullPathForDir2));
            fileUtil.AssertDirectoryExists(this.fileShare, dir1, "Base directory should be created.");
            fileUtil.AssertDirectoryExists(this.fileShare, fullPathForDir2, "Sub directory should be created.");
        }
示例#22
0
        public void ListFileShareByPrefixAndMatchingNoneTest()
        {
            string prefix = "nonexistingprefix";

            // Remove all shares starting with prefix or nonprefix
            foreach (var share in fileUtil.ListShares(prefix))
            {
                share.DeleteIfExists();
            }

            CommandAgent.GetFileShareByPrefix(prefix);
            var result = CommandAgent.Invoke();

            CommandAgent.AssertNoError();
            result.AssertNoResult();
        }
        public void CreateChainsOfDirectories()
        {
            StringBuilder expectedPathBuilder = new StringBuilder("a");

            CommandAgent.NewDirectory(this.fileShare, "a");
            for (int i = 1; i < 250; i++)
            {
                ((PowerShellAgent)CommandAgent).PowerShellSession.AddCommand("New-AzureStorageDirectory");
                ((PowerShellAgent)CommandAgent).PowerShellSession.AddParameter("Path", "a");
                expectedPathBuilder.Append("/a");
            }

            var result = CommandAgent.Invoke();

            CommandAgent.AssertNoError();
            result.AssertObjectCollection(obj => obj.AssertCloudFileDirectory(expectedPathBuilder.ToString()));
        }
示例#24
0
        public void GetFilesFromRelativePathWhereIntermediatePathMightNotExistTest()
        {
            var fileNames = Enumerable.Range(0, this.randomProvider.Next(5, 10)).Select(x => CloudFileUtil.GenerateUniqueFileName()).ToList();
            var dir       = fileUtil.EnsureFolderStructure(this.fileShare, "a/b/c");

            fileUtil.CleanupDirectory(dir);

            CommandAgent.Clear();
            IExecutionResult result;

            if (lang == Language.NodeJS)
            {
                CommandAgent.GetFile(this.fileShare, "a/c/./../b/./e/..");
                result = CommandAgent.Invoke();
                CommandAgent.AssertNoError();

                result.AssertFileListItems(Enumerable.Empty <CloudFile>(), new[] { dir });
            }
            else
            {
                CommandAgent.GetFile(this.fileShare, "a/c/./../b/./c/e/..");
                result = CommandAgent.Invoke();
                CommandAgent.AssertNoError();
                result.AssertObjectCollection(obj => obj.AssertCloudFileDirectory("a/b/c"));
            }

            CommandAgent.Clear();
            var files = fileNames.Select(name => fileUtil.CreateFile(dir, name)).ToList();

            if (lang == Language.NodeJS)
            {
                CommandAgent.GetFile(this.fileShare, "a/c/./../b/./c/e/..");
                result = CommandAgent.Invoke();
                CommandAgent.AssertNoError();

                result.AssertFileListItems(files, Enumerable.Empty <CloudFileDirectory>());
            }
            else
            {
                CommandAgent.Clear();
                CommandAgent.GetFile(this.fileShare, string.Format("a/c/./../b/./c/e/../{0}", fileNames[0]));
                result = CommandAgent.Invoke();
                CommandAgent.AssertNoError();
                result.AssertObjectCollection(obj => obj.AssertCloudFile(fileNames[0], "a/b/c"));
            }
        }
示例#25
0
        public void GetFilesFromSubDirectoryUsingRelativePathFromRootTest()
        {
            var dir = fileUtil.EnsureFolderStructure(this.fileShare, "a/b/c");

            fileUtil.CleanupDirectory(dir);

            CommandAgent.Clear();
            IExecutionResult result;

            if (lang == Language.NodeJS)
            {
                CommandAgent.GetFile(this.fileShare, "a/b/.././b/../b/");
                result = CommandAgent.Invoke();
                CommandAgent.AssertNoError();

                result.AssertFileListItems(Enumerable.Empty <CloudFile>(), new[] { dir });
            }
            else
            {
                CommandAgent.GetFile(this.fileShare, "a/b/.././b/../b/c");
                result = CommandAgent.Invoke();
                CommandAgent.AssertNoError();
                result.AssertObjectCollection(obj => obj.AssertCloudFileDirectory("a/b/c"));
            }

            CommandAgent.Clear();
            var file = fileUtil.CreateFile(dir, "d");

            if (lang == Language.NodeJS)
            {
                CommandAgent.GetFile(this.fileShare, "a/b/.././b/../b/c");
                result = CommandAgent.Invoke();
                CommandAgent.AssertNoError();

                result.AssertFileListItems(new[] { file }, Enumerable.Empty <CloudFileDirectory>());
            }
            else
            {
                CommandAgent.Clear();
                CommandAgent.GetFile(this.fileShare, "a/b/.././b/../b/c/d");
                result = CommandAgent.Invoke();
                CommandAgent.AssertNoError();
                result.AssertObjectCollection(obj => obj.AssertCloudFile("d", "a/b/c"));
            }
        }
示例#26
0
        public void GetFilesToGetFileContent()
        {
            var fileNames = Enumerable.Range(0, this.randomProvider.Next(5, 20)).Select(x => CloudFileUtil.GenerateUniqueFileName()).ToList();

            fileUtil.CleanupDirectory(this.fileShare.GetRootDirectoryReference());
            string sourceFolder = Path.Combine(Test.Data.Get("TempDir"), Utility.GenNameString(""));

            FileUtil.CreateNewFolder(sourceFolder);
            var filePaths = fileNames.Select(name => Path.Combine(sourceFolder, name)).ToList();

            foreach (var filePath in filePaths)
            {
                FileUtil.GenerateSmallFile(filePath, Utility.GetRandomTestCount(5, 10), true);
            }

            var files = fileNames.Select(name => fileUtil.CreateFile(this.fileShare, name, Path.Combine(sourceFolder, name))).ToList();

            string destFolder = Path.Combine(Test.Data.Get("TempDir"), Utility.GenNameString(""));

            FileUtil.CreateNewFolder(destFolder);
            CommandAgent.GetFile(this.fileShare, fileNames[0]);
            ((PowerShellAgent)CommandAgent).PowerShellSession.AddCommand("Get-AzureStorageFileContent");
            ((PowerShellAgent)CommandAgent).PowerShellSession.AddParameter("Destination", destFolder);
            CommandAgent.Invoke();
            CommandAgent.AssertNoError();
            string destMD5 = FileUtil.GetFileContentMD5(Path.Combine(destFolder, fileNames[0]));
            string srcMD5  = FileUtil.GetFileContentMD5(Path.Combine(sourceFolder, fileNames[0]));

            Test.Assert(destMD5.Equals(srcMD5), "Destination content should be the same with the source");

            FileUtil.CleanDirectory(destFolder);
            CommandAgent.Clear();
            CommandAgent.GetFile(this.fileShare);
            ((PowerShellAgent)CommandAgent).PowerShellSession.AddCommand("Get-AzureStorageFileContent");
            ((PowerShellAgent)CommandAgent).PowerShellSession.AddParameter("Destination", destFolder);
            CommandAgent.Invoke();
            CommandAgent.AssertNoError();

            foreach (var fileName in fileNames)
            {
                destMD5 = FileUtil.GetFileContentMD5(Path.Combine(destFolder, fileNames[0]));
                srcMD5  = FileUtil.GetFileContentMD5(Path.Combine(sourceFolder, fileNames[0]));
                Test.Assert(destMD5.Equals(srcMD5), "Destination content should be the same with the source");
            }
        }
示例#27
0
        public void UploadToAFileWhichHasJustBeenRemoved()
        {
            string localFilePath = Path.Combine(Test.Data.Get("TempDir"), CloudFileUtil.GenerateUniqueFileName());

            FileUtil.GenerateSmallFile(localFilePath, Utility.GetRandomTestCount(5, 10), true);
            string cloudFileName = CloudFileUtil.GenerateUniqueFileName();

            // Creates the file and delete it.
            var file = fileUtil.CreateFile(this.fileShare, cloudFileName);

            file.Delete();

            // Upload the file immediately
            CommandAgent.UploadFile(this.fileShare, localFilePath, cloudFileName);
            CommandAgent.Invoke();
            CommandAgent.AssertNoError();
            fileUtil.AssertFileExists(this.fileShare, cloudFileName, "File should exist after uploaded.");
        }
示例#28
0
        public void CreateFileAndListThroughPSHTest()
        {
            string fileName      = CloudFileUtil.GenerateUniqueFileName();
            string localFilePath = Path.Combine(Test.Data.Get("TempDir"), CloudFileUtil.GenerateUniqueFileName());

            byte[] randomContent = new byte[10240];
            this.randomProvider.NextBytes(randomContent);
            using (var stream = File.Create(Path.Combine(this.mountedShareRoot.FullName, fileName)))
            {
                stream.Write(randomContent, 0, randomContent.Length);
            }

            CommandAgent.GetFile(this.fileShare);
            var result = CommandAgent.Invoke();

            CommandAgent.AssertNoError();
            result.AssertObjectCollection(obj => obj.AssertCloudFile(fileName));
        }
        public void RemoveEmptyFileShareTest()
        {
            string         fileShareName = CloudFileUtil.GenerateUniqueFileShareName();
            CloudFileShare share         = fileUtil.EnsureFileShareExists(fileShareName);

            try
            {
                CommandAgent.RemoveFileShareByName(fileShareName, confirm: true);
                var result = CommandAgent.Invoke();

                CommandAgent.AssertNoError();
                result.AssertNoResult();
                Test.Assert(!share.Exists(), "The share should be removed.");
            }
            finally
            {
                fileUtil.DeleteFileShareIfExists(fileShareName);
            }
        }
示例#30
0
        public void GetFilesFromSubDirectoryUsingRelativePathTest()
        {
            var dir = fileUtil.EnsureFolderStructure(this.fileShare, "a/b/c");

            fileUtil.CleanupDirectory(dir);
            var file = fileUtil.CreateFile(dir, "d");

            CommandAgent.Clear();
            CommandAgent.GetFile(dir.Parent, "../b/./c");
            var result = CommandAgent.Invoke();

            CommandAgent.AssertNoError();
            result.AssertObjectCollection(obj => obj.AssertCloudFileDirectory("a/b/c"));

            CommandAgent.Clear();
            CommandAgent.GetFile(dir.Parent, "../b/./c/d");
            result = CommandAgent.Invoke();
            CommandAgent.AssertNoError();
            result.AssertObjectCollection(obj => obj.AssertCloudFile("d", "a/b/c"));
        }