EventRecorderT Class |
Namespace: Test.Framework
The EventRecorderT type exposes the following members.
Name | Description | |
---|---|---|
EventRecorderT |
Creates a new object.
|
Name | Description | |
---|---|---|
AllArgs |
Gets a list of every args parameter passed to the event. There will be CallCount
entries in the list.
| |
AllSenders |
Gets a list of every sender parameter passed to the event. There will be CallCount
entries in the list.
| |
Args |
Gets the args parameter from the last time the event was raised.
| |
CallCount |
Gets the number of times the event has been raised.
| |
Sender |
Gets the sender parameter from the last time the event was raised.
|
Name | Description | |
---|---|---|
Equals | (Inherited from Object.) | |
Finalize | Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. (Inherited from Object.) | |
GetHashCode | Serves as a hash function for a particular type. (Inherited from Object.) | |
GetType | Gets the Type of the current instance. (Inherited from Object.) | |
Handler |
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.
| |
MemberwiseClone | Creates a shallow copy of the current Object. (Inherited from Object.) | |
OnEventRaised |
Raises EventRaised.
| |
ToString | Returns a string that represents the current object. (Inherited from Object.) |
Name | Description | |
---|---|---|
EventRaised |
Raised by Handler(Object, T) whenever the event is raised. Can be used to test the state of
objects when the event was raised.
|
public class ObjectUnderTest() { public event EventHandler TheEvent; public void RaiseEvent() { if(TheEvent != null) TheEvent(this, EventArgs.Empty); } } [TestMethod] public void Check_That_RaiseEvent_Raises_TheEvent() { var objectUnderTest = new ObjectUnderTest(); EventRecorder<EventArgs> eventRecorder = new EventRecorder<EventArgs>(); objectUnderTest.TheEvent += eventRecorder.Handler; objectUnderTest.RaiseEvent(); Assert.AreEqual(1, eventRecorder.CallCount); Assert.AreSame(objectUnderTest, eventRecorder.Sender); Assert.IsNotNull(eventRecorder.Args); }