Пример #1
0
        public void TestCopyE2E()
        {
            var sourceTempFilePath = Path.GetTempFileName();
            var destTempFilePath   = Path.GetTempFileName();

            try
            {
                string fileName   = UploadFromString("CopyThis", 1);
                var    sourceUri  = PathToFile(fileName);
                string copyToFile = $"/{_defaultFolderName}/testFile2.txt";
                var    destUri    = PathToFile(copyToFile);
                _fileSystem.Copy(sourceUri, destUri);
                _adlsClient.BulkDownload(sourceUri.AbsolutePath, sourceTempFilePath);
                _adlsClient.BulkDownload(destUri.AbsolutePath, destTempFilePath);
                FileSystemTestUtilities.HaveSameContent(sourceTempFilePath, destTempFilePath);
            }
            finally
            {
                try
                {
                    File.Delete(sourceTempFilePath);
                }
                finally
                {
                    File.Delete(destTempFilePath);
                }
            }
        }
Пример #2
0
        public void TestExists()
        {
            var remoteUri = GetTempUri();

            Assert.False(_fileSystem.Exists(remoteUri), "The file should not exist yet");
            var localFile = FileSystemTestUtilities.MakeLocalTempFile();

            _fileSystem.CopyFromLocal(localFile, remoteUri);
            Assert.True(_fileSystem.Exists(remoteUri), "The file should now exist");
            _fileSystem.Delete(remoteUri);
            Assert.False(_fileSystem.Exists(remoteUri), "The file should no longer exist");
            File.Delete(localFile);
        }
Пример #3
0
        public void TestCopyFromLocalAndBack()
        {
            var localFile           = FileSystemTestUtilities.MakeLocalTempFile();
            var localFileDownloaded = localFile + ".2";
            var remoteUri           = GetTempUri();

            _fileSystem.CopyFromLocal(localFile, remoteUri);
            _fileSystem.CopyToLocal(remoteUri, localFileDownloaded);

            Assert.True(File.Exists(localFileDownloaded), "A file up and downloaded should exist on the local file system.");
            Assert.True(FileSystemTestUtilities.HaveSameContent(localFile, localFileDownloaded), "A file up and downloaded should not have changed content.");

            _fileSystem.Delete(remoteUri);
            File.Delete(localFile);
            File.Delete(localFileDownloaded);
        }
Пример #4
0
        public void TestGetChildren()
        {
            // Make a directory
            var remoteDirectory = GetTempUri();

            _fileSystem.CreateDirectory(remoteDirectory);

            // Check that it is empty
            Assert.AreEqual(message: "The directory should be empty.", expected: 0,
                            actual: _fileSystem.GetChildren(remoteDirectory).Count());

            // Upload some localfile there
            var localTempFile = FileSystemTestUtilities.MakeLocalTempFile();
            var remoteUri     = new Uri(remoteDirectory, Path.GetFileName(localTempFile));

            _fileSystem.CopyFromLocal(localTempFile, remoteUri);

            // Check that it is on the listing
            var uriInResult = _fileSystem.GetChildren(remoteUri).First();

            Assert.AreEqual(remoteUri, uriInResult);

            // Download the file and make sure it is the same as before
            var downloadedFileName = localTempFile + ".downloaded";

            _fileSystem.CopyToLocal(uriInResult, downloadedFileName);
            FileSystemTestUtilities.HaveSameContent(localTempFile, downloadedFileName);
            File.Delete(localTempFile);
            File.Delete(downloadedFileName);

            // Delete the file
            _fileSystem.Delete(remoteUri);

            // Check that the folder is empty again
            Assert.AreEqual(message: "The directory should be empty.", expected: 0,
                            actual: _fileSystem.GetChildren(remoteDirectory).Count());

            // Delete the folder
            _fileSystem.DeleteDirectory(remoteDirectory);
        }