Exemplo n.º 1
0
        public void ProgressUpdater(FileMoveProgressArgs progressArgs)
        {
            var transferredBytes = progressArgs.TransferredBytes;
            var totalBytes       = progressArgs.TotalBytes;
            var percent          = transferredBytes / totalBytes * 100;

            progressArgs.Cancelled = this.IsCancelled;
        }
Exemplo n.º 2
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);
        }
Exemplo n.º 3
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);
        }