Esempio n. 1
0
        public void TestNestedScopesWithSteps(int stepsCount, double childScopeSpan, int childScopeStepsCount, double[] expectedProgress)
        {
            List<double> progress = new List<double>();
            ProgressObserver progressObserver = new ProgressObserver(s => progress.Add(s.Progress));
            using (ProgressReportScope scope = new ProgressReportScope(stepsCount))
            {
                scope.Subscribe(progressObserver);
                for (int i = 0; i < stepsCount; i++)
                {
                    using (ProgressReportScope childScope = scope.CreateChildScope(childScopeStepsCount, childScopeSpan))
                    {
                        for (int j = 0; j < childScopeStepsCount; j++)
                        {
                            childScope.Increase();
                        }
                    }

                    scope.Increase();
                }
            }
            ProgressAssert.AreEqual(expectedProgress, progress);
        }
Esempio n. 2
0
 public void TestScopeWithSteps(int stepsCount, int stepsPassed, double[] expectedProgress)
 {
     List<double> progress = new List<double>();
     ProgressObserver progressObserver = new ProgressObserver(s => progress.Add(s.Progress));
     using (ProgressReportScope scope = new ProgressReportScope(stepsCount))
     {
         scope.Subscribe(progressObserver);
         for (int i = 0; i < stepsPassed; i++)
         {
             scope.Increase();
         }
     }
     ProgressAssert.AreEqual(expectedProgress, progress);
 }
Esempio n. 3
0
 public void TestScopeWithSpanAndInitProgress()
 {
     List<double> progress = new List<double>();
     ProgressObserver progressObserver = new ProgressObserver(s => progress.Add(s.Progress));
     const int steps = 3;
     using (ProgressReportScope scope = new ProgressReportScope(steps, 0.3, 0.65))
     {
         scope.Subscribe(progressObserver);
         for ( int i = 0; i < steps; i++) scope.Increase();
     }
     ProgressAssert.AreEqual(new[] { 0.75, 0.85, 0.95 }, progress);
 }