Click or drag to resize
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.Framework
Assembly: Test.Framework (in Test.Framework.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
public virtual void Handler(
	Object sender,
	T args
)

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>();

// Change the collection without attaching the event recorder:
collection.Add(987);
Assert.AreEqual(0, eventRecorder.CallCount);

// Change the collection after attaching the event recorder:
collection.CollectionChanged += eventRecorder.Handler;
collection.Add(643);
Assert.AreEqual(1, eventRecorder.CallCount);
See Also