IMockedEvent is the Typemock Isolator Event Mocking mechanism, used to fire events to test Event driven applications.
Namespace: TypeMock
Assembly: TypeMock (in TypeMock.dll) Version: 9.3.6.0 (9.3.6.0)
Syntax
The IMockedEvent type exposes the following members.
Methods
Name | Description | |
---|---|---|
![]() | Fire |
Fire a mocked event. See IMockedEvent |
![]() | GetEventHandle |
Retrieve the EventHandle
|
Remarks
When one instance of the event publisher is mocked, use MockedEvent.Fire(Object) to fire the event.
[Test] public void SimulateFiringClick() { // Mock the Click Event of the next Button Mock mockButton = MockManager.Mock(typeof(Button)); MockedEvent handler = mockButton.ExpectAddEvent("Click"); // Create the button and register to the Event Button button = new(Button); button.Click += new EventHandler(button_Click); // Simulate firing the event handler.Fire(this, EventArgs.Empty); // Check that system works... MockManager.Verify() }
[Test] public void SimulateFiringClickOnManyButtons() { // Mock all Click Events of the all Buttons Mock buttonMock = MockManager.MockAll(typeof(Button)); MockedEvent handle = buttonMock.ExpectAddEventAlways("Click"); // create 2 buttons and register to the Click Event Button button1 = new Button(); Button button2 = new Button(); button1.Click += new EventHandler(button_Click); button2.Click += new EventHandler(button_Click); // Simulate firing Click of button1 handle.Instance[0].Fire(this, EventArgs.Empty); // Simulate firing Click of button2 handle.Instance[1].Fire(this, EventArgs.Empty); // Check that system works... MockManager.Verify() }
See Also