Increased test coverage for all collection classes up to the priority queue to 100%; SetParent() is no longer 'protected internal' as internal is sufficient in this case (.NET 'protected internal' is less restrictive than 'protected' or 'internal' alone); parenting collection now unsets parent for items that are being replaced; priority queue version check for enumerators (to protected against modification of the collection) now only happens in debug mode

git-svn-id: file:///srv/devel/repo-conversion/nusu@94 d2e56fa2-650e-0410-a79f-9358c0239efd
This commit is contained in:
Markus Ewald 2008-11-27 18:56:08 +00:00
parent cb0355193d
commit c43bfd47c8
11 changed files with 663 additions and 18 deletions

View file

@ -118,6 +118,49 @@ namespace Nuclex.Support.Collections {
this.mockery.VerifyAllExpectationsHaveBeenMet();
}
/// <summary>Tests whether items in the collection can be replaced</summary>
[Test]
public void TestItemReplacement() {
Expect.Exactly(3).On(this.mockedSubscriber).
Method("ItemAdded").
WithAnyArguments();
this.observedCollection.Add(1);
this.observedCollection.Add(2);
this.observedCollection.Add(3);
Expect.Once.On(this.mockedSubscriber).
Method("ItemRemoved").
WithAnyArguments();
Expect.Once.On(this.mockedSubscriber).
Method("ItemAdded").
WithAnyArguments();
// Replace the middle item with something else
this.observedCollection[1] = 4;
Assert.AreEqual(
1,
this.observedCollection.IndexOf(4)
);
this.mockery.VerifyAllExpectationsHaveBeenMet();
}
/// <summary>Tests whether the ItemRemoved event is fired</summary>
[Test]
public void TestListConstructor() {
int[] integers = new int[] { 12, 34, 56, 78 };
ObservableCollection<int> testCollection = new ObservableCollection<int>(integers);
CollectionAssert.AreEqual(
integers,
testCollection
);
}
/// <summary>Mock object factory</summary>
private Mockery mockery;
/// <summary>The mocked observable collection subscriber</summary>