public void TestChildScopeIsAlreadeCreated() { using (ProgressReportScope scope = new ProgressReportScope()) { using (scope.CreateChildScope(0.7)) { using(scope.CreateChildScope(0.1)) DumbFunc(); } } }
public void TestChildScopeNotCompleted() { List<double> progress = new List<double>(); ProgressObserver progressObserver = new ProgressObserver(s => progress.Add(s.Progress)); using (ProgressReportScope scope = new ProgressReportScope()) { scope.Subscribe(progressObserver); scope.CreateChildScope(0.5); } ProgressAssert.AreEqual(new[] { 0.5, 1.0 }, progress); }
public void TestNestedScopes() { List<double> progress = new List<double>(); ProgressObserver progressObserver = new ProgressObserver(s => progress.Add(s.Progress)); using (ProgressReportScope scope = new ProgressReportScope()) { scope.Subscribe(progressObserver); using (scope.CreateChildScope(0.5)) DumbFunc(); using (ProgressReportScope child = scope.CreateChildScope(0.2)) { using (child.CreateChildScope(0.5)) DumbFunc(); using (child.CreateChildScope(0.5)) DumbFunc(); } } ProgressAssert.AreEqual(new[] { 0.5, 0.6, 0.7, 1.0 }, progress); }
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); }
public void TestTooBigChildScope() { using (ProgressReportScope scope = new ProgressReportScope()) { using (scope.CreateChildScope(0.7)) DumbFunc(); using (scope.CreateChildScope(0.7)) DumbFunc(); } }