Fixed unit tests that were failing due to the introdcution of the ItemReplaced event; removed NotifyCollectionResetEventArgs if no specialized collections are available
git-svn-id: file:///srv/devel/repo-conversion/nusu@257 d2e56fa2-650e-0410-a79f-9358c0239efd
This commit is contained in:
parent
2d04ad7b49
commit
13579c5162
|
@ -19,16 +19,20 @@ License along with this library
|
|||
#endregion
|
||||
|
||||
using System;
|
||||
#if !NO_SPECIALIZED_COLLECTIONS
|
||||
using System.Collections.Specialized;
|
||||
#endif
|
||||
|
||||
namespace Nuclex.Support.Collections {
|
||||
|
||||
/// <summary>Contains fixed constants used by some collections</summary>
|
||||
public static class Constants {
|
||||
|
||||
#if !NO_SPECIALIZED_COLLECTIONS
|
||||
/// <summary>Fixed event args used to notify that the collection has reset</summary>
|
||||
public static readonly NotifyCollectionChangedEventArgs NotifyCollectionResetEventArgs =
|
||||
new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Reset);
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -60,6 +60,13 @@ namespace Nuclex.Support.Collections {
|
|||
/// <param name="arguments">Contains the item that is being removed</param>
|
||||
void ItemRemoved(object sender, ItemEventArgs<KeyValuePair<int, string>> arguments);
|
||||
|
||||
/// <summary>Called when an item is replaced in the dictionary</summary>
|
||||
/// <param name="sender">Dictionary in which an item is being replaced</param>
|
||||
/// <param name="arguments">Contains the replaced item and its replacement</param>
|
||||
void ItemReplaced(
|
||||
object sender, ItemReplaceEventArgs<KeyValuePair<int, string>> arguments
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
#endregion // interface IObservableDictionarySubscriber
|
||||
|
@ -89,6 +96,10 @@ namespace Nuclex.Support.Collections {
|
|||
new EventHandler<ItemEventArgs<KeyValuePair<int, string>>>(
|
||||
this.mockedSubscriber.MockObject.ItemRemoved
|
||||
);
|
||||
this.observedDictionary.ItemReplaced +=
|
||||
new EventHandler<ItemReplaceEventArgs<KeyValuePair<int, string>>>(
|
||||
this.mockedSubscriber.MockObject.ItemReplaced
|
||||
);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -288,11 +299,9 @@ namespace Nuclex.Support.Collections {
|
|||
[Test]
|
||||
public void TestReplaceByIndexerViaGenericIDictionary() {
|
||||
this.mockedSubscriber.Expects.One.Method(
|
||||
m => m.ItemRemoved(null, null)
|
||||
).WithAnyArguments();
|
||||
this.mockedSubscriber.Expects.One.Method(
|
||||
m => m.ItemAdded(null, null)
|
||||
m => m.ItemReplaced(null, null)
|
||||
).WithAnyArguments();
|
||||
|
||||
(this.observedDictionary as IDictionary<int, string>)[42] = "two and fourty";
|
||||
this.mockery.VerifyAllExpectationsHaveBeenMet();
|
||||
|
||||
|
|
|
@ -57,6 +57,11 @@ namespace Nuclex.Support.Collections {
|
|||
/// <param name="arguments">Contains the item that is being removed</param>
|
||||
void ItemRemoved(object sender, ItemEventArgs<int> arguments);
|
||||
|
||||
/// <summary>Called when an item is replaced in the dictionary</summary>
|
||||
/// <param name="sender">Dictionary in which an item is being replaced</param>
|
||||
/// <param name="arguments">Contains the replaced item and its replacement</param>
|
||||
void ItemReplaced(object sender, ItemReplaceEventArgs<int> arguments);
|
||||
|
||||
}
|
||||
|
||||
#endregion // interface IObservableCollectionSubscriber
|
||||
|
@ -81,6 +86,9 @@ namespace Nuclex.Support.Collections {
|
|||
this.observedList.ItemRemoved += new EventHandler<ItemEventArgs<int>>(
|
||||
this.mockedSubscriber.MockObject.ItemRemoved
|
||||
);
|
||||
this.observedList.ItemReplaced += new EventHandler<ItemReplaceEventArgs<int>>(
|
||||
this.mockedSubscriber.MockObject.ItemReplaced
|
||||
);
|
||||
}
|
||||
|
||||
/// <summary>Tests whether the Clearing event is fired</summary>
|
||||
|
@ -128,8 +136,7 @@ namespace Nuclex.Support.Collections {
|
|||
this.observedList.Add(2);
|
||||
this.observedList.Add(3);
|
||||
|
||||
this.mockedSubscriber.Expects.One.Method(m => m.ItemRemoved(null, null)).WithAnyArguments();
|
||||
this.mockedSubscriber.Expects.One.Method(m => m.ItemAdded(null, null)).WithAnyArguments();
|
||||
this.mockedSubscriber.Expects.One.Method(m => m.ItemReplaced(null, null)).WithAnyArguments();
|
||||
|
||||
// Replace the middle item with something else
|
||||
this.observedList[1] = 4;
|
||||
|
|
Loading…
Reference in New Issue
Block a user