コード例 #1
0
        public void RemovesFileFromQueueWhenDeleted()
        {
            var sourceDirectory = DirectoryHelper.CreateDirectoryWithFiles();

            var targetDirectory = new MemoryDirectoryObject("targetDirectory");

            var queue   = new ManualTaskQueue();
            var syncNet = new Processor(sourceDirectory, targetDirectory, queue);

            syncNet.ProcessSourceDirectory();

            var fileToDelete = sourceDirectory.GetFiles().First();

            (fileToDelete as MemoryFileObject).Exists = false;

            queue.ExecuteAll();

            var fileObjects = targetDirectory.GetFiles().Where(x => x.Exists);

            Assert.AreEqual(1, fileObjects.Count());
            Assert.AreEqual(DirectoryHelper.FileName2, fileObjects.First().Name);
        }
コード例 #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))
                        );
        }
コード例 #3
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));
        }