public void SubDownloaderTest()
        {
            var externalDownloader = new TestDownloader();

            var currentOperationEstimation = 0;
            var currentOperationProgress   = 0;

            externalDownloader.CurrentOperationEstimationChanged +=
                (sender, args) => currentOperationEstimation      = args.Estimation;

            externalDownloader.CurrentOperationProgressChanged +=
                (sender, args) => currentOperationProgress      = args.Progress;

            Assert.AreEqual(10, externalDownloader.Estimation);
            Assert.AreEqual(0, externalDownloader.Progress);
            Assert.AreEqual(0, currentOperationEstimation);
            Assert.AreEqual(0, currentOperationProgress);

            var internalDownloader = new TestDownloader();

            Assert.AreEqual(10, internalDownloader.Estimation);
            Assert.AreEqual(0, internalDownloader.Progress);
            Assert.AreEqual(0, currentOperationEstimation);
            Assert.AreEqual(0, currentOperationProgress);

            externalDownloader.AddTestSubdownloaderAsCurrentOperation(internalDownloader);

            Assert.AreEqual(10, externalDownloader.Estimation);
            Assert.AreEqual(0, externalDownloader.Progress);
            Assert.AreEqual(10, currentOperationEstimation);
            Assert.AreEqual(0, currentOperationProgress);

            internalDownloader.DoWork();

            Assert.AreEqual(10, externalDownloader.Estimation);
            Assert.AreEqual(1, externalDownloader.Progress);
            Assert.AreEqual(10, currentOperationEstimation);
            Assert.AreEqual(1, currentOperationProgress);

            externalDownloader.DoWork();

            Assert.AreEqual(10, externalDownloader.Estimation);
            Assert.AreEqual(2, externalDownloader.Progress);
            Assert.AreEqual(10, currentOperationEstimation);
            Assert.AreEqual(1, currentOperationProgress);

            internalDownloader.ChangeEstimation(5);

            Assert.AreEqual(10, externalDownloader.Estimation);
            Assert.AreEqual(2, externalDownloader.Progress);
            Assert.AreEqual(5, currentOperationEstimation);
            Assert.AreEqual(1, currentOperationProgress);
        }
Exemple #2
0
 public void AddTestSubdownloaderAsCurrentOperation(TestDownloader internalDownloader)
 => this.AddAsCurrentOperation(internalDownloader);