public async Task ShouldRaiseCollectionChangedEventForRemoveRange() { // Arrange List <TestObservableObject> objectsToRemove = TestObservableObjectFaker.Create().Generate(10); var collection = new ObservableItemCollection <TestObservableObject>(); var tcs = new TaskCompletionSource <NotifyCollectionChangedEventArgs>(); collection.CollectionChanged += (sender, args) => { tcs.SetResult(args); }; // Act collection.RemoveRange(objectsToRemove); // Assert NotifyCollectionChangedEventArgs collectionChanged = await tcs.Task; collectionChanged.ShouldNotBeNull(); collectionChanged.OldItems.Count.ShouldBe(objectsToRemove.Count); foreach (object item in collectionChanged.OldItems) { objectsToRemove.ShouldContain(item); } }
public void ShouldRemoveRangeOfItems() { // Arrange List <TestObservableObject> items = TestObservableObjectFaker.Create().Generate(10); var itemsToRemove = items.Take(5).ToList(); var collection = new ObservableItemCollection <TestObservableObject>(items); // Act collection.RemoveRange(itemsToRemove); // Assert foreach (TestObservableObject item in itemsToRemove) { collection.ShouldNotContain(item); } }