public void ContinuousSumWithPausing() { Random rand = new Random(); DateTime start = DateTime.Now; ContinuousValue <int> sum = _source.ContinuousSum(p => p.Age); using (PausedAggregation pausedAggregation = new PausedAggregation()) { int updateIndex = 0; for (int i = 0; i < 10000; i++) { if (updateIndex >= _source.Count) { updateIndex = 0; } _source[updateIndex].Age++; if (sum.CurrentValue <= 0) { throw new Exception(); } updateIndex++; } } var duration = DateTime.Now - start; Console.WriteLine(duration.ToString()); }
public void PauseAggregation_PropertyChangedInCollection_ValueUpdatedAfterUsingBlockExits() { ContinuousValue <int> sum = _source.ContinuousSum(p => p.Age); Assert.AreEqual(30, sum.CurrentValue); int callCount = 0; sum.PropertyChanged += (sender, args) => callCount++; using (PausedAggregation pausedAggregation = new PausedAggregation()) { _source[0].Age = 1000; Assert.AreEqual(0, callCount); } Assert.AreEqual(1, callCount); }