Exemple #1
0
        public void WhenRenamingFoldersExceptionIsThrownIfDirectoryDoesNotExist()
        {
            var badDirectory = Path.Combine(_fixture.TestDirectory, Guid.NewGuid().ToString());
            var folderRename = new RenameFiles(badDirectory);

            folderRename
            .Invoking(invoke => invoke.RenameAll((x) => "10"))
            .ShouldThrow <DirectoryNotFoundException>();
        }
Exemple #2
0
        public void WhenRenamingFoldersThenFoldersAreRenamedBasedOnSeed()
        {
            CreateTestFolderSet();

            Func <string, string> seedGenerator = (x) =>
            {
                var existingX = Convert.ToInt32(x);

                return((++existingX).ToString());
            };
            var fileRename = new RenameFiles(_fixture.TestDirectory);

            fileRename.RenameAll(seedGenerator);

            _fixture.DirectoryExists("1").Should().BeTrue();
            _fixture.DirectoryExists("2").Should().BeTrue();
        }
Exemple #3
0
        private void OnRename(object sender, EventArgs e)
        {
            IRenameDiskFileAndFolders renamer = null;

            if (rbFiles.Checked)
            {
                renamer = new RenameFiles(_selectedPath);
            }
            else
            {
                renamer = new RenameFolders(_selectedPath);
            }

            renamer.RenameAll((x) => {
                var index = Convert.ToInt32(x);
                return((++index).ToString());
            });

            textBox2.Text = "Renamed in " + _selectedPath;
        }
Exemple #4
0
        static public void Main(string[] args)
        {
            if (args.Length == 1)
            {
                RenameFiles.Rename(args[0]);
            }
            else if (args.Length == 2)
            {
                string sourceDirectory = args[0];
                string targetDirectory = args[1];

                DirectoryInfo diSource = new DirectoryInfo(sourceDirectory);
                DirectoryInfo diTarget = new DirectoryInfo(targetDirectory);

                CopyDir.CopyAll(diSource, diTarget);
            }
            else
            {
                Console.WriteLine("Illegal arguments.");
            }
        }