Esempio n. 1
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);
        }