public void TestCollectionPausing() { OcConsumer consumer = new OcConsumer("Tag"); Assert.AreEqual(consumer.Tag, "Tag"); ObservableCollection <int> source = new ObservableCollection <int>(); CollectionPausing <int> collectionPausing = source.CollectionPausing().For(consumer); Assert.AreEqual(collectionPausing.IsPaused, false); collectionPausing.IsPaused = true; source.Add(1); ((INotifyCollectionChanged)collectionPausing).CollectionChanged += (sender, args) => { if (collectionPausing.IsResuming) { Assert.Throws <ObservableComputationsInconsistencyException>(() => collectionPausing.IsPaused = true); } }; collectionPausing.IsPaused = false; }
public void TestCollectionPausing() { OcConsumer consumer = new OcConsumer(); Scalar <ObservableCollection <int> > sourceScalar = new Scalar <ObservableCollection <int> >(new ObservableCollection <int>(new int[] { 1, 2, 3 }).Selecting(i => i).For(consumer)); CollectionPausing <int> collectionPausing = sourceScalar.CollectionPausing(true, CollectionPausingResumeType.ReplayChanges).For(consumer); collectionPausing.CollectionChanged += (sender, args) => { Assert.IsTrue(collectionPausing.IsResuming); }; sourceScalar.Change(new ObservableCollection <int>(new int[] { 1, 2, 3, 5, 6 }).Selecting(i => i).For(consumer)); collectionPausing.IsPaused = false; collectionPausing.ValidateInternalConsistency(); collectionPausing.IsPaused = true; sourceScalar.Change(null); collectionPausing.IsPaused = false; collectionPausing.ValidateInternalConsistency(); }