Exemplo n.º 1
0
        public static void EqualStructure(IDirectoryObject source, IDirectoryObject target)
        {
            var sourceFiles = source.GetFiles().ToList();
            var targetFiles = target.GetFiles().ToList();

            foreach (var sourceFile in sourceFiles)
            {
                Assert.IsTrue(targetFiles.Any(t => t.Name == sourceFile.Name));
            }

            var subDirectories = source.GetDirectories();

            foreach (var sourceSubDir in subDirectories)
            {
                var targetSubDir = target.GetDirectory(sourceSubDir.Name);
                Assert.IsTrue(targetSubDir.Exists);
                EqualStructure(sourceSubDir, targetSubDir);
            }
        }
Exemplo n.º 2
0
        public void RenamesFile()
        {
            IDirectoryObject sourceDirectory = DirectoryHelper.CreateDirectoryWithFile();

            IDirectoryObject targetDirectory = new MemoryDirectoryObject("targetDir");

            var mock = new Mock <ITaskQueue>();

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

            syncNet.ProcessSourceDirectory();

            var newName    = "newName.txt";
            var sourceFile = sourceDirectory.GetFiles().First();

            syncNet.RenameFile(sourceFile, newName);

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

            mock.Verify(x => x.Queue(
                            It.Is <RenameFileTask>(t => t.File.FullName == targetFile.FullName && t.NewName == newName))
                        );
        }
Exemplo n.º 3
0
        private List <IFileObject> GetFilesToCopy(IDirectoryObject source, IDirectoryObject target)
        {
            var filesToUpload = new List <IFileObject>();
            var sourceFiles   = source.GetFiles();

            foreach (var sourceFile in sourceFiles)
            {
                var targetFile = target.GetFile(sourceFile.Name);
                if (!targetFile.Exists || sourceFile.ModifiedDate >= targetFile.ModifiedDate)
                {
                    filesToUpload.Add(sourceFile);
                }
            }

            var subDirectories = source.GetDirectories();

            foreach (var sourceSubDirectory in subDirectories)
            {
                var targetSubDirectory = target.GetDirectory(sourceSubDirectory.Name);
                filesToUpload.AddRange(GetFilesToCopy(sourceSubDirectory, targetSubDirectory));
            }

            return(filesToUpload);
        }
 public ImageDirectory(IDirectoryObject directory)
 {
     Directory = directory;
     Files     = directory.GetFiles().Where(c => IsImage(c)).Cast <IFileObject>().ToArray();
     FileIndex = 0;
 }
		public ImageDirectory(IDirectoryObject directory)
		{
			Directory = directory;
			Files = directory.GetFiles().Where(c => IsImage(c)).Cast<IFileObject>().ToArray();
			FileIndex = 0;
		}