chevron-thin-right chevron-thin-left brand cancel-circle search youtube-icon google-plus-icon linkedin-icon facebook-icon twitter-icon toolbox download check linkedin phone twitter-old google-plus facebook profile-male chat calendar profile-male
Welcome to Typemock Community! Here you can ask and receive answers from other community members. If you liked or disliked an answer or thread: react with an up- or downvote.
0 votes
I was looking for a way to fake an eventhandler using the AAA syntax. Is this possible? I am trying to use this in my MVP Webforms app and have an interface, IView, defined as such:
Public Interface IView
  Event PageLoad as EventHandler  
End Interface

Do I have to manually wire this up or should I use the natural mocks? I was under the impression that you shouldn't mix the modes.
asked by underwhelmed (1.7k points)

1 Answer

0 votes
Hi,

Currently event handling is not supported by AAA. This is something we are working on and should be included in an upcoming release. In the meanwhile, you can mix APIs pretty safely by using MockManager.GetMockOf() on your fake object to get its Mock, and using that mock with either natural or reflective. The following example uses Reflective Mocks to verify a listener has been registered to the event and fire it:

Dim fake As IView = FakeInstance(Of IView)()
Dim mock As Mock = MockManager.GetMockOf(fake)
Dim mockedEvent As MockedEvent = mock.ExpectAddEvent("PageLoad")
mockedEvent.Fire(Me, EventArgs.Empty)


You can find more info about mocking events in our developer's guide: https://www.typemock.com/Docs/UserGuide/index.php

Doron
Typemock Support
answered by doron (17.2k points)
...