public void DisposeUnhooksFromClearing() { ThreadSafeBindableCollection <int> col = new ThreadSafeBindableCollection <int>(); var mock = new Mock <IListMonitor <int> >(); var releaseDelegate = mock.Object.AttachToList(col); col.Add(1); col.Clear(); mock.Verify(o => o.DestroyItem(It.IsAny <int>(), It.IsAny <int>()), Times.Once()); col.Add(1); releaseDelegate(); col.Clear(); mock.Verify(o => o.DestroyItem(It.IsAny <int>(), It.IsAny <int>()), Times.Once()); }
public void BugTestOnNotifyChangeAfterClear() { int fired = 0; smc.CollectionChanged += (s, e) => fired++; ints2.Add(12); // should work Assert.Equal(1, fired); allInts.Clear(); // now we have some outstanding property change notifications Assert.Equal(4, fired); // we get a notification for the clear operation Assert.Empty(smc); ints2.Add(13); // we get an add at an invalid index, but now the bug is fixed Assert.Equal(4, fired); // the second prop notification should be suppressed. }