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

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

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

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

            fileRename.RenameAll(seedGenerator);

            _fixture.FileExists("1.txt").Should().BeTrue();
            _fixture.FileExists("2.txt").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;
        }