public void DeleteSourceFiles_DeletesSourceFiles() { var sourceFileName = @"D:\test\Spool\fileName.sourcefile"; var sourceFiles = new List <SourceFileInfo> { new SourceFileInfo { Filename = sourceFileName } }; var jobCleanUp = new JobCleanUp(_jobTempFolder, sourceFiles, _infFile); jobCleanUp.Directory = _directory; jobCleanUp.File = _file; jobCleanUp.DoCleanUp(); _file.AssertWasCalled(dir => dir.Delete(sourceFileName)); }
public void Execute_Target_File_Exists_When_Overwriting_Should_Check_Target_ReadOnly_Flag() { IFile sourceFile = MockRepository.GenerateStub <IFile>(); sourceFile.Stub(s => s.Folder).Return(@"c:\source"); sourceFile.Stub(s => s.FileName).Return("File1"); IFile targetFile = MockRepository.GenerateStub <IFile>(); targetFile.Stub(f => f.Exists()).Return(true); targetFile.Stub(f => f.GetAttributes()).Return(FileAttributes.Normal); ICommand testCopyCommand = new MoveFileCommand(sourceFile, targetFile, true); testCopyCommand.Execute(); targetFile.AssertWasCalled(f => f.GetAttributes()); }
public void Execute_source_file_should_move_to_target() { IFile sourceFile = MockRepository.GenerateStub <IFile>(); sourceFile.Stub(s => s.Folder).Return(@"c:\source\"); sourceFile.Stub(s => s.FileName).Return("source"); IFile targetFile = MockRepository.GenerateStub <IFile>(); targetFile.Stub(s => s.Folder).Return(@"c:\source\"); targetFile.Stub(s => s.FileName).Return("target"); targetFile.Stub(s => s.Exists()).Return(false); ICommand testCopyCommand = new MoveFileCommand(sourceFile, targetFile, false); testCopyCommand.Execute(); sourceFile.AssertWasCalled(f => f.MoveFile(Arg <IFile> .Is.Same(targetFile))); }
public void Execute_target_file_exists_overwrite_target_should_be_overwritten() { IFile sourceFile = MockRepository.GenerateStub <IFile>(); sourceFile.Stub(s => s.Folder).Return(@"c:\source\"); sourceFile.Stub(s => s.FileName).Return("source"); IFile targetFile = MockRepository.GenerateStub <IFile>(); targetFile.Stub(s => s.Exists()).Return(true); targetFile.Stub(s => s.Folder).Return(@"c:\source\"); targetFile.Stub(s => s.FileName).Return("target"); ICommand testCopyCommand = new MoveFileCommand(sourceFile, targetFile, true); testCopyCommand.Execute(); sourceFile.AssertWasCalled(f => f.MoveFile(targetFile)); }
public void Execute_target_file_exists_overwrite_specified_target_deleted() { IFile sourceFile = MockRepository.GenerateStub <IFile>(); sourceFile.Stub(s => s.Exists()).Return(false); sourceFile.Stub(s => s.Folder).Return(@"c:\source\"); sourceFile.Stub(s => s.FileName).Return("source"); IFile targetFile = MockRepository.GenerateStub <IFile>(); targetFile.Stub(s => s.Exists()).Return(true); targetFile.Stub(s => s.Folder).Return(@"c:\source\"); targetFile.Stub(s => s.FileName).Return("target"); ICommand testCopyCommand = new MoveFileCommand(sourceFile, targetFile, true); testCopyCommand.Execute(); targetFile.AssertWasCalled(t => t.Delete()); }
public void Undo_Copy_success_deletes_target_file_when_undoing() { IFile sourceFile = MockRepository.GenerateStub <IFile>(); sourceFile.Stub(s => s.Exists()).Return(false); sourceFile.Stub(s => s.Folder).Return(@"c:\source\"); sourceFile.Stub(s => s.FileName).Return("source"); IFile targetFile = MockRepository.GenerateStub <IFile>(); targetFile.Stub(s => s.Exists()).Return(true); targetFile.Stub(s => s.Folder).Return(@"c:\source\"); targetFile.Stub(s => s.FileName).Return("target"); ICommand testCopyCommand = new MoveFileCommand(sourceFile, targetFile, true); testCopyCommand.Execute(); testCopyCommand.Undo(); targetFile.AssertWasCalled(t => t.Delete()); }
public void Undo_Copies_target_back_to_source_when_source_does_not_exist() { IFile sourceFile = MockRepository.GenerateStub <IFile>(); sourceFile.Stub(s => s.Exists()).Return(false); sourceFile.Stub(s => s.Folder).Return(@"c:\source\"); sourceFile.Stub(s => s.FileName).Return("source"); IFile targetFile = MockRepository.GenerateStub <IFile>(); targetFile.Stub(s => s.Exists()).Return(true); targetFile.Stub(s => s.Folder).Return(@"c:\source\"); targetFile.Stub(s => s.FileName).Return("target"); ICommand testCopyCommand = new MoveFileCommand(sourceFile, targetFile, true); testCopyCommand.Execute(); testCopyCommand.Undo(); targetFile.AssertWasCalled(x => x.MoveFile(Arg <IFile> .Is.Same(sourceFile))); }
public void Execute_Target_File_Readonly_User_Yes_Read_Only_Cleared_File_Copied() { IFile sourceFile = MockRepository.GenerateStub <IFile>(); sourceFile.Stub(s => s.Folder).Return(@"c:\source"); sourceFile.Stub(s => s.FileName).Return("File1"); IFile targetFile = MockRepository.GenerateStub <IFile>(); targetFile.Stub(f => f.Exists()).Return(true); targetFile.Stub(f => f.GetAttributes()).Return(FileAttributes.ReadOnly); ICommand testCopyCommand = new MoveFileCommand(sourceFile, targetFile, true); testCopyCommand.AskUser += (question, options) => { return(System.Windows.Forms.DialogResult.Yes); }; testCopyCommand.Execute(); targetFile.AssertWasCalled(t => t.SetAttributes(FileAttributes.Normal)); sourceFile.AssertWasCalled(s => s.MoveFile(targetFile)); }
public void MoveSingleOutputFile_CopiesTempFileToFinalDestination() { _fileMover.MoveSingleOutputFile("test", "finalDir"); _file.AssertWasCalled(f => f.Copy("test", "finalDir")); }