Exemplo n.º 1
0
        public async Task ExampleUsage2()
        {
            var timer = CountdownTimer.StartNew(100);
            await Task.Delay(10);

            IProgress p = new ProgressV2("TimerProgress", 1);

            timer.AddProgressListener(p, updateIntervalInMs: 5);
            Assert.True(10 < p.percent); // 10% of the countdown must already have passed
            await timer.timerTask;       // Wait for the end of the timer
            await Task.Delay(20);        // Delay to ensure at least one more update to p happened

            Assert.Equal(100, p.percent);
            Assert.True(p.IsComplete());
        }
Exemplo n.º 2
0
        public void ExampleUsage1()
        {
            using (IProgress progress = new ProgressV2(id: "Download Progress 1", totalCount: 10)) {
                Assert.Equal(10, progress.totalCount);

                progress.SetCount(7); // 7/10 will be complete
                Assert.Equal(70, progress.percent);

                progress.IncrementCount(); // 8/10 will be complete
                Assert.Equal(80, progress.percent);

                progress.percent = 90; // 9/10 will be complete
                Assert.Equal(9, progress.GetCount());

                progress.SetComplete(); // 10/10 will be complete
                Assert.True(progress.IsComplete());
                Assert.Equal(100, progress.percent);
            }
        }