/// <summary> /// Clears the given Collection. /// </summary> public void ClearTest(CiccioList <string> collection) { INotifyPropertyChanged collectionPropertyChanged = collection; collectionPropertyChanged.PropertyChanged += Collection_PropertyChanged; _expectedPropertyChanged = new[] { new PropertyNameExpected(COUNT), new PropertyNameExpected(ITEMARRAY) }; collection.CollectionChanged += Collection_CollectionChanged; ExpectedCollectionChangedFired++; ExpectedAction = NotifyCollectionChangedAction.Reset; ExpectedNewItems = null; ExpectedNewStartingIndex = -1; ExpectedOldItems = null; ExpectedOldStartingIndex = -1; collection.Clear(); Assert.Equal(0, collection.Count); Assert.Equal(ExpectedCollectionChangedFired, NumCollectionChangedFired); foreach (var item in _expectedPropertyChanged) { Assert.True(item.IsFound, "The propertychanged event should have fired for" + item.Name + ", since we just cleared the collection"); } collection.CollectionChanged -= Collection_CollectionChanged; collectionPropertyChanged.PropertyChanged -= Collection_PropertyChanged; }
public static void ClearTest() { string[] anArray = { "one", "two", "three", "four" }; CiccioList <string> col = new CiccioList <string>(anArray); col.Clear(); Assert.Equal(0, col.Count); Assert.Empty(col); AssertExtensions.Throws <ArgumentOutOfRangeException>("index", () => col[1]); //tests that the collectionChanged events are fired. CollectionAndPropertyChangedTester helper = new CollectionAndPropertyChangedTester(); col = new CiccioList <string>(anArray); helper.ClearTest(col); }