public void BlockReentrancy() { var collection = new ObservableCollectionSubclass <int>(); Assert.NotNull(collection.BlockReentrancy()); Assert.Same(collection.BlockReentrancy(), collection.BlockReentrancy()); }
public static void IEnumerableConstructorTest_MakesCopy(IEnumerable <string> collection) { var oc = new ObservableCollectionSubclass <string>(collection); Assert.NotNull(oc.InnerList); Assert.NotSame(collection, oc.InnerList); }
public void CheckReentrancy_MultipleListeners_MultipleBlocks() { var collection = new ObservableCollectionSubclass <int>(); collection.CollectionChanged += (sender, e) => { }; collection.CollectionChanged += (sender, e) => { }; collection.CheckReentrancy(); IDisposable block1 = collection.BlockReentrancy(); Assert.Throws <InvalidOperationException>(() => collection.CheckReentrancy()); IDisposable block2 = collection.BlockReentrancy(); Assert.Throws <InvalidOperationException>(() => collection.CheckReentrancy()); block1.Dispose(); Assert.Throws <InvalidOperationException>(() => collection.CheckReentrancy()); block2.Dispose(); collection.CheckReentrancy(); collection.CheckReentrancy(); }
public static void ListConstructorTest_MakesCopy() { List<string> collection = new List<string> { "one", "two", "three" }; var oc = new ObservableCollectionSubclass<string>(collection); Assert.NotNull(oc.InnerList); Assert.NotSame(collection, oc.InnerList); }
public void CheckReentrancy(int listenerCount, bool shouldThrow) { var collection = new ObservableCollectionSubclass <int>(); for (int i = 0; i < listenerCount; i++) { collection.CollectionChanged += (sender, e) => { }; } collection.CheckReentrancy(); using (collection.BlockReentrancy()) { if (shouldThrow) { Assert.Throws <InvalidOperationException>(() => collection.CheckReentrancy()); } else { collection.CheckReentrancy(); } } collection.CheckReentrancy(); }