Exemplo n.º 1
0
        public void DownloadFileUsingRelativePathAfterChangedDefaultLocation()
        {
            string currentPath = CommandAgent.GetCurrentLocation();

            try
            {
                string cloudFileName = CloudFileUtil.GenerateUniqueFileName();
                string localFilePath = Path.Combine(Test.Data.Get("TempDir"), CloudFileUtil.GenerateUniqueFileName());
                FileUtil.GenerateSmallFile(localFilePath, Utility.GetRandomTestCount(5, 10), true);
                var sourceFile = fileUtil.CreateFile(this.fileShare, cloudFileName, localFilePath);
                CommandAgent.ChangeLocation(Test.Data.Get("TempDir"));
                UploadAndDownloadFileInternal(
                    sourceFile,
                    FileUtil.GetFileContentMD5(localFilePath),
                    destination => CommandAgent.DownloadFile(this.fileShare, cloudFileName, ".", true));
                var result = CommandAgent.Invoke();
                result.AssertNoResult();
                Test.Assert(new FileInfo(Path.Combine(Test.Data.Get("TempDir"), cloudFileName)).Exists, "File should exist after downloaded.");
            }
            finally
            {
                CommandAgent.Clear();
                CommandAgent.ChangeLocation(currentPath);
            }
        }
Exemplo n.º 2
0
        public void UploadLocalFileUsingRelativePathAfterChangedDefaultLocation()
        {
            string currentPath = CommandAgent.GetCurrentLocation();

            try
            {
                string cloudFileName = CloudFileUtil.GenerateUniqueFileName();
                string localFilePath = Path.Combine(Test.Data.Get("TempDir"), cloudFileName);
                FileUtil.GenerateSmallFile(localFilePath, Utility.GetRandomTestCount(5, 10), true);
                CommandAgent.ChangeLocation(Test.Data.Get("TempDir"));
                CommandAgent.UploadFile(this.fileShare, cloudFileName, cloudFileName, true);
                var result = CommandAgent.Invoke();
                result.AssertNoResult();
                var file = this.fileShare.GetRootDirectoryReference().GetFileReference(cloudFileName);
                Test.Assert(file.Exists(), "File shold exist after uploaded.");
            }
            finally
            {
                CommandAgent.Clear();
                CommandAgent.ChangeLocation(currentPath);
            }
        }