예제 #1
0
        public void Run()
        {
            try {
                var prependLogic = new PrependLogic(_fileSystem);

                switch (_argumentsLogic.Command)
                {
                case CommandType.Prepend:
                    prependLogic.AddPrependText(_argumentsLogic.GetFolderPath(), _argumentsLogic.GetPrependText(), _argumentsLogic.GetFileNumberSeed(), ShowRenameDialog);
                    break;

                case CommandType.Remove:
                    prependLogic.RemovePrependedText(_argumentsLogic.GetFolderPath(), _argumentsLogic.GetPrependText(), ShowRenameDialog);
                    break;

                default:
                    Usage();
                    break;
                }
            } catch (ArgumentException ex) {
                _console.WriteLine(ex.Message);
                Usage();
            } catch (Exception ex) {
                _console.WriteLine(ex.Message);
                Usage();
            }
        }
예제 #2
0
        public void RemovePrependTextTest()
        {
            // ARRANGE
            var fakeFileSystem = new Fakes().BuildFakeFileSystemWithPrepend();
            var logic          = new PrependLogic(fakeFileSystem);

            // ACT
            logic.RemovePrependedText(@"T:\TestFiles\*.txt", "aaa### - ", ConfirmActionTrue);

            // ASSERT
            Assert.IsTrue(fakeFileSystem.FileExists(@"T:\TestFiles\file-01.txt"));
            Assert.IsTrue(fakeFileSystem.FileExists(@"T:\TestFiles\file-02.doc"));
            Assert.IsTrue(fakeFileSystem.FileExists(@"T:\TestFiles\file-03.txt"));
            Assert.IsTrue(fakeFileSystem.FileExists(@"T:\TestFiles\file-04.junk"));
            Assert.IsTrue(fakeFileSystem.FileExists(@"T:\TestFiles\file-05"));
        }