public async Task Synchronize_ShouldCallSynchronize( [Frozen]Mock<IAsyncFileOperations> fileOperations, [Frozen]Mock<IAudioTagReader> audioTagReader, [Frozen]Mock<IAudioTagWriter> audioTagWriter, AudioTagsSynchronizer sut, SourceFilePath sourceFile, TargetFilePath targetFile, Stream sourceStream, Stream targetStream, Tag tag) { //arrange fileOperations.Setup(f => f.OpenRead(sourceFile.ToString())).ReturnsTask(sourceStream); fileOperations.Setup(f => f.Open(targetFile.ToString(), Hanno.IO.FileMode.Open, Hanno.IO.FileAccess.ReadWrite)).ReturnsTask(targetStream); audioTagReader.Setup(a => a.ReadTags(It.IsAny<CancellationToken>(), sourceStream)).ReturnsTask(tag); //act await sut.SynchronizeTags(CancellationToken.None, sourceFile.File, targetFile.File); //assert audioTagWriter.Verify(a => a.WriteTags(It.IsAny<CancellationToken>(), targetStream, tag)); }
public async Task RenameFile_ShouldCallRenameFile( [Frozen]Mock<ISynchronizedFilesRepository> syncFilesRepository, [Frozen]Mock<IAsyncFileOperations> fileOperations, SynchronizeFileService sut, SourceFilePath newFilePath, SourceFilePath oldFilePath, TargetFilePath oldMirroredFilePath, TargetFilePath newMirroredFilePath ) { //arrange syncFilesRepository.Setup(s => s.GetMirroredFilePath(It.IsAny<CancellationToken>(), oldFilePath.File)) .ReturnsTask(oldMirroredFilePath.File); syncFilesRepository.Setup(s => s.GetMirroredFilePath(It.IsAny<CancellationToken>(), newFilePath.File)) .ReturnsTask(newMirroredFilePath.File); //act await sut.RenameFile(CancellationToken.None, newFilePath.File, oldFilePath.File); //assert fileOperations.Verify(f => f.Move(oldMirroredFilePath.ToString(), newMirroredFilePath.ToString())); }
public async Task HasMirroredFileForPath_ShouldReturnCorrectValue( bool expected, [Frozen]Mock<ISynchronizedFilesRepository> syncFilesRepository, [Frozen]Mock<IAsyncFileOperations> fileOperations, SynchronizeFileService sut, SourceFilePath sourceFilePath, TargetFilePath mirroredFilePath ) { //arrange syncFilesRepository.Setup(s => s.GetMirroredFilePath(It.IsAny<CancellationToken>(), sourceFilePath.File)) .ReturnsTask(mirroredFilePath.File); var tf = mirroredFilePath.ToString(); fileOperations.Setup(f => f.Exists(tf)).ReturnsTask(expected); //act var actual = await sut.HasMirroredFileForPath(CancellationToken.None, sourceFilePath.File); //assert actual.Should().Be(expected); }
public async Task DeleteFile_ShouldCallDeleteFile( [Frozen]Mock<ISynchronizedFilesRepository> syncFilesRepository, [Frozen]Mock<IAsyncFileOperations> fileOperations, SynchronizeFileService sut, SourceFilePath sourceFilePath, TargetFilePath mirroredFilePath ) { //arrange syncFilesRepository.Setup(s => s.GetMirroredFilePath(It.IsAny<CancellationToken>(), sourceFilePath.File)) .ReturnsTask(mirroredFilePath.File); //act await sut.DeleteFile(CancellationToken.None, sourceFilePath.File); //assert fileOperations.Verify(f => f.Delete(mirroredFilePath.ToString())); }