EventRecorderTHandler Method |
An event handler matching the EventHandler and/or EventHandler<> delegate that can be attached
to an event and record the parameters passed by the code that raises the event.
Namespace: Test.FrameworkAssembly: Test.Framework (in Test.Framework.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax public virtual void Handler(
Object sender,
T args
)
Public Overridable Sub Handler (
sender As Object,
args As T
)
public:
virtual void Handler(
Object^ sender,
T args
)
abstract Handler :
sender : Object *
args : 'T -> unit
override Handler :
sender : Object *
args : 'T -> unit
Parameters
- sender
- Type: SystemObject
- args
- Type: T
Examples
Many of the examples already illustrate this, but just to emphasise that this class needs to be hooked
to the event that you want to test, this is how you do it:
ObservableCollection<int> collection = new ObservableCollection<int>();
EventRecorder<NotifyCollectionChangedEventArgs> eventRecorder = new EventRecorder<NotifyCollectionChangedEventArgs>();
collection.Add(987);
Assert.AreEqual(0, eventRecorder.CallCount);
collection.CollectionChanged += eventRecorder.Handler;
collection.Add(643);
Assert.AreEqual(1, eventRecorder.CallCount);
See Also