public void ReportProgressToSink(int total, int increment, int chunkSize, int[] expectedPercentages) { List <int> actualPercentages = new List <int>(); Int32ChunkedPercentageStrategy strategy = new Int32ChunkedPercentageStrategy(chunkSize); strategy.Subscribe(progressData => { actualPercentages.Add(progressData.PercentComplete); }); Int32ProgressSink sink = new Int32ProgressSink(initialTotal: total); sink.Subscribe(strategy); int iterationCount = total / increment; for (int iteration = 0; iteration <= iterationCount; iteration++) { sink.Add(increment); } Assert.Equal(expectedPercentages.Length, actualPercentages.Count); Assert.Equal(expectedPercentages, actualPercentages); }
public void ReportProgressToStrategy(int total, int increment, int chunkSize, int[] expectedPercentages) { List <int> actualPercentages = new List <int>(); Int32ChunkedPercentageStrategy strategy = new Int32ChunkedPercentageStrategy(chunkSize); strategy.Subscribe(progressData => { actualPercentages.Add(progressData.PercentComplete); }); int adjustedTotal = AdjustTotalForIncrement(total, increment); for (int currentProgress = 0; currentProgress <= adjustedTotal; currentProgress += increment) { strategy.AsObserver().OnNext( RawProgressData.Create(currentProgress, total) ); } Assert.Equal(expectedPercentages.Length, actualPercentages.Count); Assert.Equal(expectedPercentages, actualPercentages); }