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'm trying to mock an event in WCF. I'm using AAA, which I know doesn't support events yet. I tried to follow this:

https://www.typemock.com/community/viewt ... ight=event

but it doesn't work. Here's what I'm trying to do:

Isolate.Fake.StaticMethods<OperationContext>(Members.ReturnRecursiveFakes);

OperationContext.Current.Host.Closing += this.OnHostClosing;

var host = MockManager.GetMockOf<ServiceHostBase>(
OperationContext.Current.Host);
var hostClosing = host.ExpectAddEvent("Closing");
hostClosing.Fire(OperationContext.Current.Host, EventArgs.Empty);

I get this error:

Test method TypeMock.TypeMockException: *** No handlers are registered to the event.

Any insight would be greatly appreciated.

Regards,
Jason Bock
asked by jasonbock (1.2k points)

1 Answer

0 votes
I got it to work, I just needed to move the code that attaches the this.OnHostClosing call after I call ExpectAddEvent() but before Fire(). Then all is well.
answered by jasonbock (1.2k points)
...