public void itShouldRenameUsingFilenameToken()
        {
            string inputFile1 = @"C:\someDir\someFile1.txt";
            string inputFile2 = @"C:\someDir\someFile2.txt";

            string pattern        = "preText-[n]-postText.txt";
            var    fileSysCommand = new MockFileSystemCommand();
            var    fakeFileSystem = new FakeFileSystem(fileSysCommand);

            fakeFileSystem.AddFiles(inputFile1, inputFile2);
            var renameFileCommand = new MultiFileRenameWithPatternCommand(pattern, fileSysCommand, inputFile1, inputFile2);

            renameFileCommand.Do();

            var outputFile1 = @"C:\someDir\preText-someFile1-postText.txt";
            var outputFile2 = @"C:\someDir\preText-someFile2-postText.txt";

            Assert.IsTrue(renameFileCommand.DidCommandSucceed);

            Assert.AreEqual(renameFileCommand.RenamedFiles[inputFile1], outputFile1);
            Assert.AreEqual(renameFileCommand.RenamedFiles[inputFile2], outputFile2);

            Assert.IsTrue(fakeFileSystem.FileExists(outputFile1));
            Assert.IsTrue(fakeFileSystem.FileExists(outputFile2));
        }
Beispiel #2
0
        public void itShouldDeleteOnlyCopiedFilesOnUndo()
        {
            var fileSysCommand = new MockFileSystemCommand();
            var sourceDir      = @"c:\sourceDir";
            var sourceDirFile1 = @"c:\sourceDir\file1.txt";
            var sourceDirFile2 = @"c:\sourceDir\file2.txt";

            var targetDir              = @"c:\targetDir";
            var targetDirFile1         = @"c:\targetDir\file2.txt";
            var dirCopyContentsCommand = new DirectoryCopyContentsCommand(sourceDir, targetDir, fileSysCommand);
            var fakeFileSystem         = new FakeFileSystem(fileSysCommand);

            fakeFileSystem.AddDirectory(sourceDir);
            fakeFileSystem.AddFiles(sourceDirFile1);
            fakeFileSystem.AddFiles(sourceDirFile2);

            fakeFileSystem.AddDirectory(targetDir);
            fakeFileSystem.AddFiles(targetDirFile1);

            dirCopyContentsCommand.Do();

            Assert.IsFalse(dirCopyContentsCommand.DidCommandSucceed);
            Assert.IsTrue(fakeFileSystem.FileExists(targetDirFile1));

            dirCopyContentsCommand.Undo();

            Assert.IsFalse(fakeFileSystem.FileExists(@"c:\targetDir\file1.txt"));
            Assert.IsTrue(fakeFileSystem.FileExists(targetDirFile1));
        }
Beispiel #3
0
        public void itShouldDeleteTargetZipOnUndoIfCommandSucceeded()
        {
            var zipExe        = "dummy7zip.exe";
            var targetZipFile = @"dummytargetZip.7z";
            var source1       = "file1.txt";
            var source2       = "file2.txt";
            var zip7FileCompressionCommand = new Zip7CompressCommand(zipExe, targetZipFile, source1, source2);

            zip7FileCompressionCommand.setFileCompressionStrategy(new MockFileCompressionStrategy(0));
            var mockFileSysCommand = new MockFileSystemCommand();

            zip7FileCompressionCommand.setFileSystemCommandsStrategy(mockFileSysCommand);
            var fakeFileSystem = new FakeFileSystem(mockFileSysCommand);

            fakeFileSystem.AddFiles(source1);
            fakeFileSystem.AddFiles(source2);
            fakeFileSystem.AddFiles(zipExe);

            zip7FileCompressionCommand.Do();
            Assert.IsTrue(zip7FileCompressionCommand.DidCommandSucceed);

            fakeFileSystem.AddFiles(targetZipFile);

            zip7FileCompressionCommand.Undo();
            Assert.IsFalse(fakeFileSystem.FileExists(targetZipFile));
        }
        public void itShouldRevertNameOnUndoButOnlyForThoseThatWereRenamed()
        {
            string inputFile1 = @"C:\someDir\someFile1.txt";
            string inputFile2 = @"C:\someDir\someFile2.txt";
            string inputFile3 = @"C:\someDir\someFile3.txt";

            string pattern        = "preText-[n]-postText.txt";
            var    fileSysCommand = new MockFileSystemCommand();
            var    fakeFileSystem = new FakeFileSystem(fileSysCommand);

            fakeFileSystem.AddFiles(inputFile1, inputFile2, inputFile3);
            var fileRenameCommand = new MultiFileRenameWithPatternCommand(pattern, fileSysCommand, inputFile1, inputFile2, inputFile3);
            var outputFile1       = @"C:\someDir\preText-someFile1-postText.txt";
            var outputFile2       = @"C:\someDir\preText-someFile2-postText.txt";
            var outputFile3       = @"C:\someDir\preText-someFile3-postText.txt";

            fakeFileSystem.AddFiles(outputFile3);

            fileRenameCommand.Do();

            Assert.IsFalse(fileRenameCommand.DidCommandSucceed);

            fileRenameCommand.Undo();

            Assert.IsFalse(fakeFileSystem.FileExists(outputFile1));
            Assert.IsFalse(fakeFileSystem.FileExists(outputFile2));
            Assert.IsTrue(fakeFileSystem.FileExists(outputFile3));
        }
Beispiel #5
0
        public void itShouldFailIfDeleteFails()
        {
            var fileSysCommand = new MockFileSystemCommand();
            var fakeFileSystem = new FakeFileSystem(fileSysCommand);

            fileSysCommand.FileDeleteFunc = (filename) => {
                throw new ApplicationException("Exception raised by MockFileSystemCommand during FileDelete");
            };
            var source = @"c:\dummysourcefile.txt";

            fakeFileSystem.AddFiles(source);
            var fileDeleteCommand = new FileDeleteCommand(@"c:\dummybackupdir", fileSysCommand, source);
            var reports           = new List <CommandReport>();

            fileDeleteCommand.OnReportSent += (command, args) => {
                reports.Add(new CommandReport {
                    Reporter   = command,
                    Message    = args.Message,
                    ReportType = args.ReportType
                });
            };

            fileDeleteCommand.Do();
            Assert.IsFalse(fileDeleteCommand.DidCommandSucceed);
            Assert.IsTrue(reports.Any(r => r.ReportType == ReportType.DoneTaskWithFailure &&
                                      r.Reporter.Id == fileDeleteCommand.Id));
        }
        public void itShouldRenameUsingDateTimeToken()
        {
            string inputFile1 = @"C:\someDir\someFile1.txt";
            string inputFile2 = @"C:\someDir\someFile2.txt";

            string pattern        = "preText-[n]-[d:MMdd]-postText.txt";
            var    fileSysCommand = new MockFileSystemCommand();
            var    fakeFileSystem = new FakeFileSystem(fileSysCommand);

            fakeFileSystem.AddFiles(inputFile1, inputFile2);
            var renameFileCommand = new MultiFileRenameWithPatternCommand(pattern, fileSysCommand, inputFile1, inputFile2);

            renameFileCommand.Do();

            var computedReplacement = renameFileCommand.DateTimeReference.ToString("MMdd");
            var targetFile1         = $@"C:\someDir\preText-someFile1-{computedReplacement}-postText.txt";
            var targetFile2         = $@"C:\someDir\preText-someFile2-{computedReplacement}-postText.txt";

            Assert.IsTrue(renameFileCommand.DidCommandSucceed);
            Assert.AreEqual(renameFileCommand.RenamedFiles[inputFile1], targetFile1);
            Assert.AreEqual(renameFileCommand.RenamedFiles[inputFile2], targetFile2);

            Assert.IsTrue(fakeFileSystem.FileExists(targetFile1));
            Assert.IsTrue(fakeFileSystem.FileExists(targetFile2));
        }
        public void itShouldSucceedIfSourceDiretoryDoesNotExist()
        {
            var fileSysCommand   = new MockFileSystemCommand();
            var dirToDelete      = @"c:\dummyDir";
            var dirDeleteCommand = new DirectoryDeleteCommand(dirToDelete, @"c:\dummybackupdir", fileSysCommand);
            var fakeFileSystem   = new FakeFileSystem(fileSysCommand);

            dirDeleteCommand.Do();
            Assert.IsTrue(dirDeleteCommand.DidCommandSucceed);
        }
Beispiel #8
0
        public void itShouldFailIfSourceDirectoryDoesNotExist()
        {
            var fileSysCommand         = new MockFileSystemCommand();
            var sourceDir              = @"c:\sourceDir";
            var targetDir              = @"c:\targetDir";
            var dirCopyContentsCommand = new DirectoryCopyContentsCommand(sourceDir, targetDir, fileSysCommand);
            var fakeFileSystem         = new FakeFileSystem(fileSysCommand);

            dirCopyContentsCommand.Do();

            Assert.IsFalse(dirCopyContentsCommand.DidCommandSucceed);
        }
        public void itShouldFailIfOneOfTheSourceFilesDoesNotExist()
        {
            var fileSysCommand = new MockFileSystemCommand();
            var fakeFileSystem = new FakeFileSystem(fileSysCommand);

            var    inputFiles        = new string[] { @"C:\someDir\someFile.txt", @"C:\someDir\someFile2.txt" };
            string pattern           = "preText-[n]-postText.txt";
            var    fileRenameCommand = new MultiFileRenameWithPatternCommand(pattern, fileSysCommand, inputFiles);

            fileRenameCommand.Do();

            Assert.IsFalse(fileRenameCommand.DidCommandSucceed);
        }
Beispiel #10
0
        public void itShouldFailIfSourceFileDoesNotExist()
        {
            var fileSysCommand  = new MockFileSystemCommand();
            var fakeFileSystem  = new FakeFileSystem(fileSysCommand);
            var fileToCopy      = @"c:\dummysourcefile.txt";
            var targetFileCopy  = @"c:\somefolder\dummysourcefile.doc";
            var fileCopyCommand = new FileCopyCommand(@"c:\dummybackupdir", fileSysCommand, fileToCopy, targetFileCopy);

            fileCopyCommand.Do();

            Assert.IsFalse(fileCopyCommand.DidCommandSucceed);
            Assert.IsFalse(fakeFileSystem.FileExists(targetFileCopy));
        }
Beispiel #11
0
        public void itShouldFailIfFileCopyPairCountIsOdd()
        {
            var fileSysCommand  = new MockFileSystemCommand();
            var fakeFileSystem  = new FakeFileSystem(fileSysCommand);
            var fileToCopy1     = @"c:\dummysourcefile.txt";
            var targetFileCopy1 = @"c:\somefolder\dummytargetfile.doc";
            var fileToCopy2     = @"c:\dummysourcefile2.txt";

            fakeFileSystem.AddFiles(fileToCopy1, fileToCopy2);
            var fileCopyCommand = new FileCopyCommand(@"c:\dummybackupdir", fileSysCommand, fileToCopy1, targetFileCopy1, fileToCopy2);

            fileCopyCommand.Do();
        }
        public void itShouldFailIfTokenOpeningBracketsAreMismatched()
        {
            string inputFile      = @"C:\someDir\someFile.txt";
            string pattern        = "preText-[[n]-postText.txt";
            var    fileSysCommand = new MockFileSystemCommand();
            var    fakeFileSystem = new FakeFileSystem(fileSysCommand);

            fakeFileSystem.AddFiles(inputFile);
            var fileRenameCommand = new MultiFileRenameWithPatternCommand(pattern, fileSysCommand, inputFile);

            fileRenameCommand.Do();

            Assert.IsFalse(fileRenameCommand.DidCommandSucceed);
        }
        public void itShouldFailIfReplacementTokenIsUnrecognized()
        {
            string inputFile      = @"C:\someDir\someFile.txt";
            string pattern        = "preText-[X:abcd]-postText.txt";
            var    fileSysCommand = new MockFileSystemCommand();
            var    fakeFileSystem = new FakeFileSystem(fileSysCommand);

            fakeFileSystem.AddFiles(inputFile);
            var fileRenameCommand = new MultiFileRenameWithPatternCommand(pattern, fileSysCommand, inputFile);

            fileRenameCommand.Do();

            Assert.IsFalse(fileRenameCommand.DidCommandSucceed);
        }
Beispiel #14
0
        public void itShouldDeleteBackupFileOnCleanup()
        {
            var fileSysCommand = new MockFileSystemCommand();
            var fakeFileSystem = new FakeFileSystem(fileSysCommand);

            var fileToDelete = @"c:\dummysourcefile.txt";

            fakeFileSystem.AddFiles(fileToDelete);
            var fileDeleteCommand = new FileDeleteCommand(@"c:\dummybackupdir", fileSysCommand, fileToDelete);

            fileDeleteCommand.Do();
            fileDeleteCommand.Cleanup();

            Assert.IsFalse(fakeFileSystem.FileExists(fileDeleteCommand.BackupFilename));
        }
Beispiel #15
0
        public void itShouldRestoreBackupOnUndo()
        {
            var fileSysCommand = new MockFileSystemCommand();
            var fakeFileSystem = new FakeFileSystem(fileSysCommand);
            var fileToDelete   = @"c:\dummysourcefile.txt";

            fakeFileSystem.AddFiles(fileToDelete);
            var fileDeleteCommand = new FileDeleteCommand(@"c:\dummybackupdir", fileSysCommand, fileToDelete);

            fileDeleteCommand.Do();
            Assert.IsFalse(fakeFileSystem.FileExists(fileToDelete));

            fileDeleteCommand.Undo();
            Assert.IsTrue(fakeFileSystem.FileExists(fileToDelete));
        }
        public void itShouldDeleteBackupFileOnCleanup()
        {
            var fileSysCommand = new MockFileSystemCommand();
            var fakeFileSystem = new FakeFileSystem(fileSysCommand);

            var dirToDelete = @"c:\main1\main2\dummysourceDir";

            fakeFileSystem.AddDirectory(dirToDelete);
            var dirDeleteCommand = new DirectoryDeleteCommand(dirToDelete, @"c:\dummybackupdir", fileSysCommand);

            dirDeleteCommand.Do();
            dirDeleteCommand.Cleanup();

            Assert.IsFalse(fakeFileSystem.DirectoryExists(dirDeleteCommand.BackedUpDirectory));
        }
        public void itShouldRestoreBackupOnUndo()
        {
            var fileSysCommand = new MockFileSystemCommand();
            var fakeFileSystem = new FakeFileSystem(fileSysCommand);
            var dirToDelete    = @"c:\mainFolder\dummysourcedir";

            fakeFileSystem.AddDirectory(dirToDelete);
            var dirDeleteCommand = new DirectoryDeleteCommand(dirToDelete, @"c:\dummybackupdir", fileSysCommand);

            dirDeleteCommand.Do();
            Assert.IsFalse(fakeFileSystem.DirectoryExists(dirToDelete));

            dirDeleteCommand.Undo();
            Assert.IsTrue(fakeFileSystem.DirectoryExists(dirToDelete));
        }
Beispiel #18
0
        public void itShouldFailIfDestinationFileAlreadyExists()
        {
            var fileSysCommand = new MockFileSystemCommand();
            var fakeFileSystem = new FakeFileSystem(fileSysCommand);
            var fileToCopy     = @"c:\dummysourcefile.txt";
            var targetFileCopy = @"c:\somefolder\dummysourcefile.doc";

            fakeFileSystem.AddFiles(fileToCopy);
            fakeFileSystem.AddFiles(targetFileCopy);
            var fileCopyCommand = new FileCopyCommand(@"c:\dummybackupdir", fileSysCommand, fileToCopy, targetFileCopy);

            fileCopyCommand.Do();

            Assert.IsFalse(fileCopyCommand.DidCommandSucceed);
        }
        public void itShouldFailIfDeleteFails()
        {
            var fileSysCommand   = new MockFileSystemCommand();
            var sourceDir        = @"c:\dummysourcefile";
            var dirDeleteCommand = new DirectoryDeleteCommand(sourceDir, @"c:\dummybackupdir", fileSysCommand);
            var fakeFileSystem   = new FakeFileSystem(fileSysCommand);

            fileSysCommand.DirectoryDeleteFunc = (filename) => {
                throw new ApplicationException("Exception raised by MockFileSystemCommand during FileDelete");
            };
            fakeFileSystem.AddDirectory(sourceDir);

            dirDeleteCommand.Do();
            Assert.IsFalse(dirDeleteCommand.DidCommandSucceed);
            Assert.IsTrue(fakeFileSystem.DirectoryExists(sourceDir));
        }
Beispiel #20
0
        public void itShouldHaveCopiedFileIfSuccessful()
        {
            var fileSysCommand = new MockFileSystemCommand();
            var fakeFileSystem = new FakeFileSystem(fileSysCommand);

            var fileToCopy     = @"c:\dummysourcefile.txt";
            var targetFileCopy = @"c:\somefolder\dummysourcefile.doc";

            fakeFileSystem.AddFiles(fileToCopy);
            var fileCopyCommand = new FileCopyCommand(@"c:\dummybackupdir", fileSysCommand, fileToCopy, targetFileCopy);

            fileCopyCommand.Do();

            Assert.IsTrue(fileCopyCommand.DidCommandSucceed);
            Assert.IsTrue(fakeFileSystem.FileExists(targetFileCopy));
        }
        public void itShouldFailIfOneOfTheTargetFilesAlreadyExists()
        {
            var fileSysCommand = new MockFileSystemCommand();
            var fakeFileSystem = new FakeFileSystem(fileSysCommand);

            var    inputFiles        = new string[] { @"C:\someDir\someFile.txt" };
            string pattern           = "preText-[n]-postText.txt";
            var    fileRenameCommand = new MultiFileRenameWithPatternCommand(pattern, fileSysCommand, inputFiles);
            var    outputFile        = @"C:\someDir\preText-someFile-postText.txt";

            fakeFileSystem.AddFiles(inputFiles);
            fakeFileSystem.AddFiles(outputFile);

            fileRenameCommand.Do();

            Assert.IsFalse(fileRenameCommand.DidCommandSucceed);
        }
        public void itShouldFailIfBackupFails()
        {
            var fileSysCommand   = new MockFileSystemCommand();
            var sourceDir        = @"c:\dummysourceDir";
            var dirDeleteCommand = new DirectoryDeleteCommand(sourceDir, @"c:\dummybackupdir", fileSysCommand);
            var fakeFileSystem   = new FakeFileSystem(fileSysCommand);

            fileSysCommand.DirectoryCopyContentsFunc = (sourceFile, destinationFile, preCopyCallback, postCopyCallback) => {
                throw new ApplicationException("Exception raised by MockFileSystemCommand during DirectoryCopy");
            };
            fakeFileSystem.AddDirectory(sourceDir);

            dirDeleteCommand.Do();

            Assert.IsFalse(dirDeleteCommand.DidCommandSucceed);
            Assert.IsTrue(fakeFileSystem.DirectoryExists(sourceDir));
        }
Beispiel #23
0
        public void itShouldFailIfTargetZipAlreadyExists()
        {
            var targetZipFile = @"dummytargetZip.7z";
            var zip7FileCompressionCommand = new Zip7CompressCommand("dummy7zip.exe", targetZipFile, "file1.txt", "file2.txt");

            zip7FileCompressionCommand.setFileCompressionStrategy(new MockFileCompressionStrategy());
            var mockFileSysCommand = new MockFileSystemCommand();

            zip7FileCompressionCommand.setFileSystemCommandsStrategy(mockFileSysCommand);
            var fakeFileSystem = new FakeFileSystem(mockFileSysCommand);

            fakeFileSystem.AddFiles(targetZipFile);

            zip7FileCompressionCommand.Do();

            Assert.IsFalse(zip7FileCompressionCommand.DidCommandSucceed);
        }
        public void itShouldRenameUsingMultipleFilenameTokens()
        {
            string inputFile1     = @"C:\someDir\someFile.txt";
            string pattern        = "preText-[n]-postText-[n].txt";
            var    fileSysCommand = new MockFileSystemCommand();
            var    fakeFileSystem = new FakeFileSystem(fileSysCommand);

            fakeFileSystem.AddFiles(inputFile1);
            var renameFileCommand = new MultiFileRenameWithPatternCommand(pattern, fileSysCommand, inputFile1);

            renameFileCommand.Do();

            var targetFile = @"C:\someDir\preText-someFile-postText-someFile.txt";

            Assert.AreEqual(renameFileCommand.RenamedFiles[inputFile1], targetFile);
            Assert.IsTrue(fakeFileSystem.FileExists(targetFile));
        }
Beispiel #25
0
        public void itShouldInterpretNonZeroReturnValueFromFileCompressionStrategyAsFailure()
        {
            var targetZipFile = @"dummytargetZip.7z";
            var zip7FileCompressionCommand = new Zip7CompressCommand("dummy7zip.exe", targetZipFile, "file1.txt", "file2.txt");

            zip7FileCompressionCommand.setFileCompressionStrategy(new MockFileCompressionStrategy(1));
            var mockFileSysCommand = new MockFileSystemCommand();

            zip7FileCompressionCommand.setFileSystemCommandsStrategy(mockFileSysCommand);
            var fakeFileSystem = new FakeFileSystem(mockFileSysCommand);

            zip7FileCompressionCommand.Do();

            Assert.IsFalse(zip7FileCompressionCommand.DidCommandSucceed);

            zip7FileCompressionCommand.setFileCompressionStrategy(new MockFileCompressionStrategy(-1));
            Assert.IsFalse(zip7FileCompressionCommand.DidCommandSucceed);
        }
        public void itShouldSucceedWhenThereAreNoReplacementTokens()
        {
            string inputFile      = @"C:\someDir\someFile.txt";
            string pattern        = "newFileName.txt";
            var    fileSysCommand = new MockFileSystemCommand();
            var    fakeFileSystem = new FakeFileSystem(fileSysCommand);

            fakeFileSystem.AddFiles(inputFile);
            var fileRenameCommand = new MultiFileRenameWithPatternCommand(pattern, fileSysCommand, inputFile);

            fileRenameCommand.Do();

            Assert.IsTrue(fileRenameCommand.DidCommandSucceed);
            var outputFile = @"C:\someDir\newFileName.txt";

            Assert.AreEqual(fileRenameCommand.RenamedFiles[inputFile], outputFile);
            Assert.IsTrue(fakeFileSystem.FileExists(outputFile));
        }
        public void itShouldRenameUsingFileExtensionTokenEvenIfSourceHasNoExtension()
        {
            string inputFile      = @"C:\someDir\someFileNoExt";
            string pattern        = "renamed-[n][e]";
            var    fileSysCommand = new MockFileSystemCommand();
            var    fakeFileSystem = new FakeFileSystem(fileSysCommand);

            fakeFileSystem.AddFiles(inputFile);
            var renameFileCommand = new MultiFileRenameWithPatternCommand(pattern, fileSysCommand, inputFile);

            renameFileCommand.Do();

            Assert.IsTrue(renameFileCommand.DidCommandSucceed);
            var outputFile = $@"C:\someDir\renamed-someFileNoExt";

            Assert.AreEqual(renameFileCommand.RenamedFiles[inputFile], outputFile);
            Assert.IsTrue(fakeFileSystem.FileExists(outputFile));
        }
Beispiel #28
0
        public void itShouldFailIfAnyOfTheTargetFilesAlreadyExist()
        {
            var fileSysCommand         = new MockFileSystemCommand();
            var sourceDir              = @"c:\sourceDir";
            var sourceDirFile1         = @"c:\sourceDir\file1.txt";
            var targetDir              = @"c:\targetDir";
            var targetDirFile1         = @"c:\targetDir\file1.txt";
            var dirCopyContentsCommand = new DirectoryCopyContentsCommand(sourceDir, targetDir, fileSysCommand);
            var fakeFileSystem         = new FakeFileSystem(fileSysCommand);

            fakeFileSystem.AddDirectory(sourceDir);
            fakeFileSystem.AddFiles(sourceDirFile1);
            fakeFileSystem.AddDirectory(targetDir);
            fakeFileSystem.AddFiles(targetDirFile1);

            dirCopyContentsCommand.Do();

            Assert.IsFalse(dirCopyContentsCommand.DidCommandSucceed);
        }
        public void itShouldRenameUsingFilenameAndDateTimeToken()
        {
            string inputFile      = @"C:\someDir\someFile.txt";
            string pattern        = "preText-[n]-postText-[d:MMdd].txt";
            var    fileSysCommand = new MockFileSystemCommand();
            var    fakeFileSystem = new FakeFileSystem(fileSysCommand);

            fakeFileSystem.AddFiles(inputFile);
            var renameFileCommand = new MultiFileRenameWithPatternCommand(pattern, fileSysCommand, inputFile);

            renameFileCommand.Do();

            Assert.IsTrue(renameFileCommand.DidCommandSucceed);
            var computedReplacement = renameFileCommand.DateTimeReference.ToString("MMdd");
            var outputFile          = $@"C:\someDir\preText-someFile-postText-{computedReplacement}.txt";

            Assert.AreEqual(renameFileCommand.RenamedFiles[inputFile], outputFile);
            Assert.IsTrue(fakeFileSystem.FileExists(outputFile));
        }
Beispiel #30
0
        public void itShouldFailIfOneOrMoreSourcesDoNotExist()
        {
            var zipExe        = "dummy7zip.exe";
            var targetZipFile = @"dummytargetZip.7z";
            var sourceFile1   = "file1.txt";
            var sourceFile2   = "file2.txt";
            var zip7FileCompressionCommand = new Zip7CompressCommand(zipExe, targetZipFile, sourceFile1, sourceFile2);

            zip7FileCompressionCommand.setFileCompressionStrategy(new MockFileCompressionStrategy());
            var mockFileSysCommand = new MockFileSystemCommand();

            zip7FileCompressionCommand.setFileSystemCommandsStrategy(mockFileSysCommand);
            var fakeFileSystem = new FakeFileSystem(mockFileSysCommand);

            fakeFileSystem.AddFiles(zipExe);

            zip7FileCompressionCommand.Do();

            Assert.IsFalse(zip7FileCompressionCommand.DidCommandSucceed);
        }