public void CheckedFilesAreDeleted() { // Arrange GroupFile deleteThis1 = new GroupFile() { FullName = @"c:\folder\delete1.png", Checked = true }; GroupFile deleteThis2 = new GroupFile() { FullName = @"c:\somewhere\delete2.jpg", Checked = true }; IDuplicateReaderFactory readerFactory = this.ArrangeReaderFactoryForGroups( this.ArrangeGroup(deleteThis1, deleteThis2)); IFileModifier fileModifer = Substitute.For <IFileModifier>(); DuplicateProcessor uut = this.DuplicateProcessorWithDefaultMocks( readerFactory: readerFactory, fileModifier: fileModifer); // Act uut.ProcessDuplicates(); // Assert fileModifer.Received().Delete(deleteThis1); fileModifer.Received().Delete(deleteThis2); }
public void NoModificationsIfNoCheckedFiles() { // Arrange IDuplicateReaderFactory readerFactory = this.ArrangeReaderFactoryForGroups( this.ArrangeGroup( new GroupFile() { Checked = false }, new GroupFile() { Checked = false })); IFileModifier fileModifier = Substitute.For <IFileModifier>(); DuplicateProcessor uut = this.DuplicateProcessorWithDefaultMocks( readerFactory: readerFactory, fileModifier: fileModifier); // Act uut.ProcessDuplicates(); // Assert fileModifier.DidNotReceive().Delete(Arg.Any <GroupFile>()); fileModifier.DidNotReceive().Move(Arg.Any <GroupFile>(), Arg.Any <string>()); }
private DuplicateProcessor DuplicateProcessorWithDefaultMocks( IDuplicateReaderFactory readerFactory = null, IFileModifier fileModifier = null, IDuplicateHandlerConfiguration config = null, IFileSystem fileSystem = null) { if (fileSystem == null) { FileSystem fs = new FileSystem(); fileSystem = Substitute.For <IFileSystem>(); fileSystem.Path.Returns(Substitute.For <PathBase>()); fileSystem.Path.GetDirectoryName(Arg.Any <string>()) .Returns(callInfo => fs.Path.GetDirectoryName(callInfo.Arg <string>())); fileSystem.Path.Combine(Arg.Any <string>(), Arg.Any <string>()) .Returns(callInfo => fs.Path.Combine(callInfo.ArgAt <string>(0), callInfo.ArgAt <string>(1))); } return(new DuplicateProcessor( readerFactory: readerFactory ?? Substitute.For <IDuplicateReaderFactory>(), config: config ?? Substitute.For <IDuplicateHandlerConfiguration>(), fileSystem: fileSystem, fileModifier: fileModifier ?? Substitute.For <IFileModifier>())); }
private void CreateMp3Song(bool paramFileExists) { this.mp3File = new MockMp3File(InitTitle, InitArtist, InitAlbum); this.fileModifier = new MockFileModifier(paramFileExists); this.mp3Song = new Mp3Song(this.mp3File, this.fileModifier); }
public void GetFileModifierWithFileAlreadyExistsIsTrue() { // Act IFileModifier mp3File = this.mockModelFactory.CreateFileModifier(true); // Assert Assert.IsTrue(mp3File.FileExists(null)); }
public DuplicateProcessor( IDuplicateReaderFactory readerFactory, IFileModifier fileModifier, IDuplicateHandlerConfiguration config, IFileSystem fileSystem) { _readerFactory = readerFactory; _fileModifier = fileModifier; _config = config; _fileSystem = fileSystem; }
/// <summary> /// <para>Конструктор. Возвращает экземпляр <see cref="T:GZipTest.GZipModifier"/></para> /// <para>Принимает:</para> <para><paramref name="gZipStreamCommand"></paramref> - /// режим работы <see cref="T:System.IO.Compression.GZipStream"/> /// (<paramref name="gZipStreamCommand"></paramref>)</para> /// <para>полное имя (<paramref name="fileToReadPath"></paramref>) читаемого файла</para> /// <para>полное имя (<paramref name="fileToWritePath"></paramref>) записываемого файла</para> /// </summary> #region constructor public GZipModifier(CompressionMode gZipStreamCommand, string fileToReadPath, string fileToWritePath) { threadsNumber = Environment.ProcessorCount; threadPool = new Thread[threadsNumber]; this.gZipStreamCommand = gZipStreamCommand; this.fileToReadPath = fileToReadPath; this.fileToWritePath = fileToWritePath; args = new string[] { gZipStreamCommand.ToString(), fileToReadPath, fileToWritePath }; fileModifier = ModifierFactory.Create(gZipStreamCommand); readQueue = new LimitedSizeBlocksQueue(threadsNumber); writeBuffer = new ConcurrentDictionary <int, Block>(); countdown = new CountdownEvent(threadsNumber + 1); canAddBlockToBuffer = true; allBlocksWriten = false; blocksReaded = 0; }
public void StagedFilesReplaceCheckedGoodFile() { // Arrange IDuplicateHandlerConfiguration config = Substitute.For <IDuplicateHandlerConfiguration>(); config.GoodPath.Returns(@"c:\good"); GroupFile goodFile = new GroupFile() { FullName = config.GoodPath + @"\decent.jpg", Checked = true }; GroupFile stagedFile1 = new GroupFile() { FullName = @"c:\staged\better.png", Checked = false }; GroupFile stagedFile2 = new GroupFile() { FullName = @"c:\staged\better_v2.png", Checked = false }; IDuplicateReaderFactory readerFactory = this.ArrangeReaderFactoryForGroups( this.ArrangeGroup(goodFile, stagedFile1, stagedFile2)); IFileModifier fileModifier = Substitute.For <IFileModifier>(); DuplicateProcessor uut = this.DuplicateProcessorWithDefaultMocks( config: config, fileModifier: fileModifier, readerFactory: readerFactory); // Act uut.ProcessDuplicates(); // Assert fileModifier.Received(1).Delete(goodFile); fileModifier.Received(1).Move(stagedFile1, config.GoodPath); fileModifier.Received(1).Move(stagedFile2, config.GoodPath); }
public void StagedFileIsNotMovedIfMultipleGoodPathsFound() { // Arrange IDuplicateHandlerConfiguration config = Substitute.For <IDuplicateHandlerConfiguration>(); config.GoodPath.Returns(@"c:\good"); GroupFile goodFile1 = new GroupFile() { FullName = config.GoodPath + @"\folder1\decent.jpg", Checked = true }; GroupFile goodFile2 = new GroupFile() { FullName = config.GoodPath + @"\folder2\ok.jpg", Checked = true }; GroupFile stagedFile = new GroupFile() { FullName = @"c:\staged\better.png", Checked = false }; IDuplicateReaderFactory readerFactory = this.ArrangeReaderFactoryForGroups( this.ArrangeGroup(goodFile1, goodFile2, stagedFile)); IFileModifier fileModifier = Substitute.For <IFileModifier>(); DuplicateProcessor uut = this.DuplicateProcessorWithDefaultMocks( config: config, readerFactory: readerFactory, fileModifier: fileModifier); // Act uut.ProcessDuplicates(); // Assert fileModifier.Received(1).Delete(goodFile1); fileModifier.Received(1).Delete(goodFile2); fileModifier.DidNotReceive().Move(Arg.Any <GroupFile>(), Arg.Any <string>()); }
public Mp3Song(IMp3File paramMp3File, IFileModifier paramFileModifier) { this.mp3File = paramMp3File; this.fileModifier = paramFileModifier; }
public SyncFolderGroup(IEnumerable <ISyncFolderPair> syncFolderPairs, IValidator validator, IFileModifier fileModifier) { _syncFolderPairs = syncFolderPairs; _validator = validator; _fileModifier = fileModifier; }
public Modifier(IFileModifier fileModifier, IDirectoryModifier directoryModifier) { _fileModifier = fileModifier; _directoryModifier = directoryModifier; }