I’m wanting to test that a class has an EventHandler assigned to an event. Basically I’m using my IoC Container to hook up EventHandlers for me, and I’m wanting to check they get assigned properly. So really, I’m testing my IoC config.
[Test] public void create_person_event_handler_is_hooked_up_by_windsor() { IChangePersonService changePersonService = IoC.Resolve<IChangePersonService>(); // check that changePersonService.PersonCreated has a handler attached }
I’m not sure how to test that changePersonService.PersonCreated has anything attached to it though.
Any ideas?
Thanks.
Not questioning what you pretend with this, the only way of testing and enumerating the registered events is if your register them in your own collection.
See this example:
Then you could access the registered handlers with prop
PersonEventHandlers.Can you implement something like this?