Esempio n. 1
0
        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);
        }
Esempio n. 2
0
        public void Add(int total, int initialValue, int amountToAdd, int expectedCurrent)
        {
            IProgressSink <int> progressSink = new Int32ProgressSink(total, initialValue);

            progressSink.Add(amountToAdd);

            Assert.Equal(total, progressSink.Total);
            Assert.Equal(expectedCurrent, progressSink.Current);
        }