示例#1
0
        public void RenameFileOnS3FileSystem()
        {
            var syncNet = new Processor(_sourceObject, _targetDirectory, new SyncTaskQueue());

            syncNet.ProcessSourceDirectory();

            var fileToRename = _sourceObject.GetDirectories().First().GetFiles().First();

            syncNet.RenameFile(fileToRename, "newName.txt");

            var fileInfos = _s3DirectoryInfo.GetDirectories().First().GetFiles();

            Assert.IsTrue(fileInfos.Any(x => x.Name == "newName.txt"));
            Assert.IsFalse(fileInfos.Any(x => x.Name == fileToRename.Name));
        }
        public void UploadsFile()
        {
            var subDirectorPath = Path.Combine(_testDirectory, _subDirectoryName);

            if (!Directory.Exists(subDirectorPath))
            {
                Directory.CreateDirectory(subDirectorPath);
            }

            File.WriteAllText(Path.Combine(_testDirectory, _subDirectoryName, _subFileName),
                              _contents);

            var sourceDirectory = new LocalDirectoryObject(_testDirectory);

            var targetDirectory = new MemoryDirectoryObject("dir");

            var syncNet = new Processor(sourceDirectory, targetDirectory, new SyncTaskQueue());

            syncNet.CopyFile(
                new LocalFileObject(sourceDirectory.FullName + "\\" + _subDirectoryName + "\\" + _subFileName));

            var subDirectory = targetDirectory.GetDirectories().First();

            Assert.AreEqual(_subDirectoryName, subDirectory.Name);

            var fileObject = subDirectory.GetFiles().First();

            Assert.AreEqual(_subFileName, fileObject.Name);
            using (var sr = new StreamReader(fileObject.GetStream()))
            {
                Assert.AreEqual(_contents, sr.ReadToEnd().Replace("\0", string.Empty));
            }
        }
示例#3
0
        public void RenamesDirectory()
        {
            IDirectoryObject sourceDirectory = DirectoryHelper.CreateFullDirectory();

            IDirectoryObject targetDirectory = new MemoryDirectoryObject("targetDir");

            var mock = new Mock <ITaskQueue>();

            var syncNet = new Processor(sourceDirectory, targetDirectory, mock.Object);

            syncNet.ProcessSourceDirectory();

            var newName      = "newName";
            var subDirectory = sourceDirectory.GetDirectories().First();

            syncNet.RenameDirectory(subDirectory, newName);

            var targetFile = targetDirectory.GetDirectories().First();

            mock.Verify(x => x.Queue(
                            It.Is <RenameDirectoryTask>(t => t.Directory.FullName == targetFile.FullName && t.NewName == newName))
                        );
        }
示例#4
0
        public void CreatesDirectoryStructure()
        {
            var sourceDirectory = DirectoryHelper.CreateFullDirectory();

            IDirectoryObject targetDirectory = new MemoryDirectoryObject("directory");

            var syncNet = new Processor(sourceDirectory, targetDirectory, new SyncTaskQueue());

            syncNet.ProcessSourceDirectory();

            Assert.AreEqual(2, targetDirectory.GetFiles().Count());

            var subDirectories = targetDirectory.GetDirectories();

            Assert.AreEqual(1, subDirectories.Count());
            Assert.AreEqual(DirectoryHelper.SubDirectoryName, subDirectories.First().Name);

            var files = subDirectories.First().GetFiles();

            Assert.AreEqual(2, files.Count());

            Assert.IsTrue(files.Any(x => x.Name == DirectoryHelper.SubFileName));
            Assert.IsTrue(files.Any(x => x.Name == DirectoryHelper.SubFileName2));
        }