Esempio n. 1
0
        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);
        }
Esempio n. 2
0
        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);
        }
Esempio n. 3
0
        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);
        }
Esempio n. 4
0
        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;
        }
Esempio n. 5
0
        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);
        }