public void FileMoverCancelSetsCancelOnEventArgs() { this.IsCancelled = true; var fileMover = new FileMoverInternal(new Mock <IProgressFileMover>().Object, "source", "dest", ProgressUpdater); var fileMoverEventArgs = new FileMoveProgressArgs(1, 1); fileMover.ProgressCallback(fileMoverEventArgs); this.IsCancelled = false; Assert.IsTrue(fileMoverEventArgs.Cancelled); }
public async Task FileMoveFailsIfDestExistsAndOverwriteIsFalse() { CreateTestFile(); var sourcePath = TestFilePath; var destPath = TestFilePath; Mock <IProgressFileMover> _mockMover = new Mock <IProgressFileMover>(); var fileMover = new FileMoverInternal(_mockMover.Object, sourcePath, destPath, ProgressUpdater, false); var result = await fileMover.MoveAsync(FileMoveType.Move); }
public async Task FileMovePassesIfDestExistsAndOverwriteIsTrue() { CreateTestFile(); var sourcePath = TestFilePath; var destPath = TestFilePath; Mock <IProgressFileMover> _mockMover = new Mock <IProgressFileMover>(); _mockMover.Setup(mover => mover.MoveFile(It.IsAny <string>(), It.IsAny <string>(), FileMoveType.Move, It.IsAny <Action <FileMoveProgressArgs> >())).ReturnsAsync(true); var fileMover = new FileMoverInternal(_mockMover.Object, sourcePath, destPath, ProgressUpdater, true); var result = await fileMover.MoveAsync(FileMoveType.Move); Assert.IsTrue(result); }
public async Task FileMoverSetsIsMoving() { CreateTestFile(); var sourcePath = TestFilePath; var destPath = TestFilePath; Mock <IProgressFileMover> mockMover = new Mock <IProgressFileMover>(); mockMover.Setup(mover => mover.MoveFile(It.IsAny <string>(), It.IsAny <string>(), FileMoveType.Move, It.IsAny <Action <FileMoveProgressArgs> >())).Returns(async() => { await Task.Delay(1000); return(true); }); var filemover = new FileMoverInternal(mockMover.Object, sourcePath, destPath, ProgressUpdater); var result = filemover.MoveAsync(FileMoveType.Move); Assert.IsTrue(filemover.IsMoving); await result; }
public void FileMoverUpdatesProgressUpdater() { var totalBytes = 0L; var transferredBytes = 0L; Action <FileMoveProgressArgs> _progressUpdated = (FileMoveProgressArgs progressArgs) => { totalBytes = progressArgs.TotalBytes; transferredBytes = progressArgs.TransferredBytes; progressArgs.Cancelled = false; }; var fileMover = new FileMoverInternal(new Mock <IProgressFileMover>().Object, "source", "dest", _progressUpdated); var fileMoverEventArgs = new FileMoveProgressArgs(100, 50); fileMover.ProgressCallback(fileMoverEventArgs); Assert.AreEqual(100, totalBytes); Assert.AreEqual(50, transferredBytes); }