public void Clean_EmptyRootFolder_EmptyFileRegistry()
        {
            _folderNamesGenerator = path => Enumerable.Empty <string>();
            _fileNamesGenerator   = path => Enumerable.Empty <string>();

            _cleaner.Clean("root");

            _uniqueNames.Should().BeEmpty();
            _backedUpNames.Should().BeEmpty();
        }
示例#2
0
        public void CleanupTest()
        {
            var input = new List <ItemDescriptor>
            {
                new DirectoryDescriptor(@"D:\DIR\proj1", ".git"),
                new FileDescriptor(@"D:\DIR\proj2", "solution.sln"),
                new DirectoryDescriptor(@"D:\DIR\proj3", ".git"),
                new FileDescriptor(@"D:\DIR\proj3", "solution.sln"),
                new DirectoryDescriptor(@"D:\DIR\proj4", ".git"),
                new FileDescriptor(@"D:\DIR\proj4\subdir", "solution.sln"),
            };

            var sut    = new DuplicateCleaner();
            var result = sut.Clean(input);

            var expected = new List <ItemDescriptor>
            {
                new DirectoryDescriptor(@"D:\DIR\proj1", ".git"),
                new FileDescriptor(@"D:\DIR\proj2", "solution.sln"),
                new FileDescriptor(@"D:\DIR\proj3", "solution.sln"),
                new DirectoryDescriptor(@"D:\DIR\proj4", ".git"),
                new FileDescriptor(@"D:\DIR\proj4\subdir", "solution.sln"),
            };

            CollectionAssert.AreEqual(expected, result);
        }
示例#3
0
        public void Execute()
        {
            using (var backupManager = new BackupDirectoryManager(_rootFolder, _backupFolder))
            {
                backupManager.CreateBackupDirectory();
                var backedUpFileRegistry = new BackedUpFilesRegistry(backupManager);
                var folderNamesProvider  = new DirectoryProvider(backupManager.BackupRoot);

                var cleaner = new DuplicateCleaner(
                    new UniqueFilesRegistry(),
                    backedUpFileRegistry,
                    new FileProvider(),
                    folderNamesProvider);

                cleaner.Clean(_rootFolder);
            }
        }