public void PipelineCreatingMultipleDirectoriesWhileSomeDirectoryExistsTest() { int numberOfDirectories = this.randomProvider.Next(2, 33); int[] indexes = Enumerable.Range(0, numberOfDirectories).ToArray(); string[] names = indexes.Select(i => CloudFileUtil.GenerateUniqueDirectoryName()).ToArray(); int numberOfExistingDirectories = this.randomProvider.Next(1, numberOfDirectories); List <int> indexToBeRemoved = new List <int>(indexes); for (int i = 0; i < numberOfExistingDirectories; i++) { int id = this.randomProvider.Next(indexToBeRemoved.Count); fileUtil.EnsureDirectoryExists(this.fileShare, names[indexToBeRemoved[id]]); indexToBeRemoved.RemoveAt(id); } CommandAgent.NewDirectoryFromPipeline(this.fileShare.Name); var result = CommandAgent.Invoke(names); // A total number of "numberOfExistingDirectories" errors should throw while others should success. CommandAgent.AssertErrors(err => err.AssertError(AssertUtil.ResourceAlreadyExistsFullQualifiedErrorId), numberOfExistingDirectories); // Assert all directories are created foreach (string name in names) { fileUtil.AssertDirectoryExists(this.fileShare, name, string.Format("Directory {0} should exist after created.", name)); } }
public void CreateDirectoryWithInvalidCharacters() { string dirName = FileNamingGenerator.GenerateASCIINameWithInvalidCharacters(this.randomProvider.Next(3, FileNamingGenerator.MaxFileNameLength + 1)); this.CreateDirectoryInternal(dirName, false); CommandAgent.AssertErrors(err => err.AssertError(AssertUtil.InvalidArgumentFullQualifiedErrorId)); }
public void CreateDirectoryWith256Chars() { string dirName = FileNamingGenerator.GenerateValidateASCIIName(FileNamingGenerator.MaxFileNameLength + 1); this.CreateDirectoryInternal(dirName, false); CommandAgent.AssertErrors(err => err.AssertError(AssertUtil.InvalidArgumentFullQualifiedErrorId)); }
public void CreateDirectoryUnderRootsParent() { string dirName = CloudFileUtil.GenerateUniqueDirectoryName(); this.CreateDirectoryInternal("../" + dirName, false); CommandAgent.AssertErrors(err => err.AssertError(AssertUtil.InvalidResourceFullQualifiedErrorId, AssertUtil.AuthenticationFailedFullQualifiedErrorId)); }
public void CreateCasePreservingExistingDirectoryTest() { int length = this.randomProvider.Next(5, 50); string dirName = FileNamingGenerator.GenerateNameFromRange(length, new Tuple <int, int>((int)'a', (int)'z')); var directory = fileUtil.EnsureDirectoryExists(this.fileShare, dirName); // Randomly up case some letters StringBuilder sb = new StringBuilder(dirName); for (int i = 0; i < sb.Length; i++) { // 1/3 chance to up case the letters if (this.randomProvider.Next(3) == 0) { sb[i] = Char.ToUpperInvariant(sb[i]); } } string newDirName = sb.ToString(); Test.Info("Original dir name: {0}. New dir name: {1}.", dirName, newDirName); CommandAgent.NewDirectory(this.fileShare, newDirName); var result = CommandAgent.Invoke(); CommandAgent.AssertErrors(err => err.AssertError(AssertUtil.ResourceAlreadyExistsFullQualifiedErrorId)); }
public void GetShareSnapshot_notExistTime() { string shareName = CloudFileUtil.GenerateUniqueFileShareName(); try { CloudFileShare share = fileUtil.EnsureFileShareExists(shareName); CloudFileShare shareSnapshot1 = share.Snapshot(); CommandAgent.GetFileShareByName(shareName, DateTime.Now.AddDays(-1)); var result = CommandAgent.Invoke(); CommandAgent.AssertErrors(record => record.AssertError(AssertUtil.ResourceNotFoundFullQualifiedErrorId)); result.AssertNoResult(); } finally { try { fileUtil.DeleteFileShareIfExists(shareName); } catch (Exception e) { Test.Warn("Unexpected exception when cleanup file share {0}: {1}", shareName, e); } } }
public void RemoveRootDirectoryTest() { CommandAgent.RemoveDirectory(this.fileShare, "/"); var result = CommandAgent.Invoke(); CommandAgent.AssertErrors(record => record.AssertError(AssertUtil.InvalidResourceFullQualifiedErrorId, AssertUtil.AuthenticationFailedFullQualifiedErrorId)); }
public void DownloadToAnNonExistingFilePath() { string cloudFileName = CloudFileUtil.GenerateUniqueFileName(); string localFilePath = Path.Combine(Test.Data.Get("TempDir"), CloudFileUtil.GenerateUniqueFileName()); string localExistingPath = Path.Combine(Test.Data.Get("TempDir"), CloudFileUtil.GenerateUniqueFileName()); FileUtil.GenerateSmallFile(localFilePath, Utility.GetRandomTestCount(5, 10), true); var destinationFolder = new DirectoryInfo(Path.Combine(Test.Data.Get("TempDir"), CloudFileUtil.GenerateUniqueDirectoryName())); if (destinationFolder.Exists) { destinationFolder.Delete(true); } var sourceFile = fileUtil.CreateFile(this.fileShare, cloudFileName, localFilePath); UploadAndDownloadFileInternal( sourceFile, FileUtil.GetFileContentMD5(localFilePath), destination => CommandAgent.DownloadFile(sourceFile, destination, false), () => Path.Combine(destinationFolder.FullName, CloudFileUtil.GenerateUniqueFileName()), false); CommandAgent.AssertErrors(err => err.AssertError(AssertUtil.TransferExceptionFullQualifiedErrorId, AssertUtil.ResourceNotFoundFullQualifiedErrorId)); }
public void DownloadFileUsingNullFileObjectTest() { ((PowerShellAgent)CommandAgent).PowerShellSession.AddScript("Get-AzureStorageFileContent -File $null -Destination ."); var result = CommandAgent.Invoke(); result.AssertNoResult(); CommandAgent.AssertErrors(err => err.AssertError(AssertUtil.ParameterArgumentValidationErrorFullQualifiedErrorId)); }
public void ListFilesUsingNullDirectoryObjectTest() { ((PowerShellAgent)CommandAgent).PowerShellSession.AddScript("Get-AzureStorageFile -Directory $null"); var result = CommandAgent.Invoke(); result.AssertNoResult(); CommandAgent.AssertErrors(err => err.AssertError(AssertUtil.ParameterArgumentValidationErrorFullQualifiedErrorId)); }
public void NewShareWithEmptyNameTest() { ((PowerShellAgent)CommandAgent).PowerShellSession.AddScript("New-AzureStorageShare -Name \"\""); var result = CommandAgent.Invoke(); result.AssertNoResult(); CommandAgent.AssertErrors(err => err.AssertError(AssertUtil.ParameterArgumentValidationErrorFullQualifiedErrorId)); }
public void GetShareByPrefixUsingWildCardTest() { string shareName = string.Concat("*", CloudFileUtil.GenerateUniqueFileShareName()); CommandAgent.GetFileShareByPrefix(shareName); CommandAgent.Invoke(); CommandAgent.AssertErrors(err => err.AssertError(AssertUtil.InvalidArgumentFullQualifiedErrorId)); }
public void NewDirectoryWithNullShareObjectTest() { ((PowerShellAgent)CommandAgent).PowerShellSession.AddScript("New-AzureStorageDirectory -Share $null -Path dir"); var result = CommandAgent.Invoke(); result.AssertNoResult(); CommandAgent.AssertErrors(err => err.AssertError(AssertUtil.ParameterArgumentValidationErrorFullQualifiedErrorId)); }
public void CreateDirectoryWithNoPath_FileShareName() { ((PowerShellAgent)CommandAgent).PowerShellSession.AddScript("New-AzureStorageDirectory -ShareName " + this.fileShare.Name); var result = CommandAgent.Invoke(); result.AssertNoResult(); CommandAgent.AssertErrors(err => err.AssertError(AssertUtil.MissingMandatoryParameterFullQualifiedErrorId)); }
public void UploadFileFromSubDirectoryOfRootTest() { string localFilePath = Path.Combine(Test.Data.Get("TempDir"), CloudFileUtil.GenerateUniqueFileName()); FileUtil.GenerateSmallFile(localFilePath, Utility.GetRandomTestCount(5, 10), true); CommandAgent.UploadFile(this.fileShare, localFilePath, "../a"); CommandAgent.Invoke(); CommandAgent.AssertErrors(err => err.AssertError(AssertUtil.InvalidResourceFullQualifiedErrorId, AssertUtil.AuthenticationFailedFullQualifiedErrorId)); }
public void RemoveDirectoryWithNoPath_FileShare() { CommandAgent.SetVariable("share", this.fileShare); ((PowerShellAgent)CommandAgent).PowerShellSession.AddScript("Remove-AzureStorageDirectory -Share $share"); var result = CommandAgent.Invoke(); result.AssertNoResult(); CommandAgent.AssertErrors(err => err.AssertError(AssertUtil.MissingMandatoryParameterFullQualifiedErrorId)); }
public void CreateExistingDirectoryTest() { string dirName = CloudFileUtil.GenerateUniqueDirectoryName(); var directory = fileUtil.EnsureDirectoryExists(this.fileShare, dirName); CommandAgent.NewDirectory(this.fileShare, dirName); var result = CommandAgent.Invoke(); CommandAgent.AssertErrors(err => err.AssertError(AssertUtil.ResourceAlreadyExistsFullQualifiedErrorId)); }
public void DownloadingNonExistingFile() { string cloudFileName = CloudFileUtil.GenerateUniqueFileName(); var file = fileUtil.DeleteFileIfExists(this.fileShare, cloudFileName); CommandAgent.DownloadFile(file, Test.Data.Get("TempDir"), true); var result = CommandAgent.Invoke(); CommandAgent.AssertErrors(err => err.AssertError(AssertUtil.InvalidOperationExceptionFullQualifiedErrorId, AssertUtil.PathNotFoundFullQualifiedErrorId, AssertUtil.ResourceNotFoundFullQualifiedErrorId)); }
public void CreateShareWithInvalidCharactersTest_TooLong() { this.CreateShareInternal( () => FileNamingGenerator.GenerateValidShareName(64), (results, shareName) => { CommandAgent.AssertErrors(err => err.AssertError(AssertUtil.InvalidArgumentFullQualifiedErrorId)); }, false); }
public void RemoveDirectoryUnderNonExistingShareTest() { string shareName = CloudFileUtil.GenerateUniqueFileShareName(); string dir = CloudFileUtil.GenerateUniqueDirectoryName(); fileUtil.DeleteFileShareIfExists(shareName); CommandAgent.RemoveDirectory(shareName, dir); var result = CommandAgent.Invoke(); CommandAgent.AssertErrors(record => record.AssertError(AssertUtil.ShareNotFoundFullQualifiedErrorId)); }
public void RemoveNonExistingDirectoryTest() { string dir = CloudFileUtil.GenerateUniqueDirectoryName(); fileUtil.DeleteDirectoryIfExists(this.fileShare, dir); CommandAgent.RemoveDirectory(this.fileShare, dir); var result = CommandAgent.Invoke(); CommandAgent.AssertErrors(record => record.AssertError(AssertUtil.ResourceNotFoundFullQualifiedErrorId)); }
public void CreateDirectoryWithNoPath_Directory() { var dir = fileUtil.EnsureDirectoryExists(this.fileShare, CloudFileUtil.GenerateUniqueDirectoryName()); CommandAgent.SetVariable("dir", dir); ((PowerShellAgent)CommandAgent).PowerShellSession.AddScript("New-AzureStorageDirectory -Directory $dir"); var result = CommandAgent.Invoke(); result.AssertNoResult(); CommandAgent.AssertErrors(err => err.AssertError(AssertUtil.MissingMandatoryParameterFullQualifiedErrorId)); }
public void RemoveNonExistingFile() { string fileName = CloudFileUtil.GenerateUniqueFileName(); fileUtil.DeleteFileIfExists(this.fileShare, fileName); CommandAgent.RemoveFile(this.fileShare, fileName); var result = CommandAgent.Invoke(); CommandAgent.AssertErrors(err => err.AssertError(AssertUtil.ResourceNotFoundFullQualifiedErrorId)); }
public void UploadAFileWithInvalidSpecialName() { string localFilePath = Path.Combine(Test.Data.Get("TempDir"), CloudFileUtil.GenerateUniqueFileName()); FileUtil.GenerateSmallFile(localFilePath, Utility.GetRandomTestCount(5, 10), true); string cloudFileName = "CLOCK$"; CommandAgent.UploadFile(this.fileShare, localFilePath, cloudFileName); CommandAgent.Invoke(); CommandAgent.AssertErrors(err => err.AssertError(AssertUtil.InvalidArgumentFullQualifiedErrorId)); }
public void CreateDirectoryUnderNonExistingFileShareTest() { string nonExistingFileShareName = CloudFileUtil.GenerateUniqueFileShareName(); fileUtil.DeleteFileShareIfExists(nonExistingFileShareName); string dirName = CloudFileUtil.GenerateUniqueDirectoryName(); CommandAgent.NewDirectory(nonExistingFileShareName, dirName); var result = CommandAgent.Invoke(); CommandAgent.AssertErrors(err => err.AssertError(AssertUtil.ShareNotFoundFullQualifiedErrorId)); }
public void CreateDirectoryUnderNonExistingShare() { string shareName = CloudFileUtil.GenerateUniqueFileShareName(); string dirName = CloudFileUtil.GenerateUniqueDirectoryName(); fileUtil.DeleteFileShareIfExists(shareName); this.CreateDirectoryInternal( () => CommandAgent.NewDirectory(shareName, dirName), dirName, false); CommandAgent.AssertErrors(err => err.AssertError(AssertUtil.ShareNotFoundFullQualifiedErrorId)); }
public void CreateShareWithInvalidCharactersTest_UpperCase() { int length = this.randomProvider.Next(10, 60); this.CreateShareInternal( () => FileNamingGenerator.GenerateInvalidShareName_UpperCase(length), (results, shareName) => { CommandAgent.AssertErrors(err => err.AssertError(AssertUtil.InvalidArgumentFullQualifiedErrorId)); }, false); }
public void GetNonExistingShareTest() { string shareName = CloudFileUtil.GenerateUniqueFileShareName(); fileUtil.DeleteFileShareIfExists(shareName); CommandAgent.GetFileShareByName(shareName); CommandAgent.Invoke(); CommandAgent.AssertErrors(err => err.AssertError( AssertUtil.ResourceNotFoundFullQualifiedErrorId, AssertUtil.ShareNotFoundFullQualifiedErrorId, AssertUtil.ShareBeingDeletedFullQualifiedErrorId)); }
public void UploadToADeletedFolder() { string localFilePath = Path.Combine(Test.Data.Get("TempDir"), CloudFileUtil.GenerateUniqueFileName()); FileUtil.GenerateSmallFile(localFilePath, Utility.GetRandomTestCount(5, 10), true); var dir = fileUtil.EnsureDirectoryExists(this.fileShare, CloudFileUtil.GenerateUniqueDirectoryName()); dir.Delete(); CommandAgent.UploadFile(this.fileShare, localFilePath, CloudFileUtil.GetFullPath(dir) + "/"); CommandAgent.Invoke(); CommandAgent.AssertErrors(err => err.AssertError(AssertUtil.ParentNotFoundFullQualifiedErrorId)); }
public void RemoveNonEmptyDirectoryTest() { string dir = CloudFileUtil.GenerateUniqueDirectoryName(); var directory = fileUtil.EnsureDirectoryExists(this.fileShare, dir); fileUtil.CreateFile(directory, CloudFileUtil.GenerateUniqueFileName()); CommandAgent.RemoveDirectory(this.fileShare, dir); var result = CommandAgent.Invoke(); CommandAgent.AssertErrors(record => record.AssertError(AssertUtil.DirectoryNotEmptyFullQualifiedErrorId)); }