title: How can I test that an event contains an event handler?
body: <p>I want to test that class <code>A</code>'s <code>RegisterEventHandlers()</code> method registers one of its methods as an <code>EventHandler</code> for an event on class <code>B</code>. How can I do that? I'm using moq, if that matters.</p>
  
  <ul>
  <li>I don't think there's a way to inspect the event handler delegate from outside the class (please correct me if I'm wrong).</li>
  <li>It'd be nice if I could trigger the event and then assert that my callback was called, but if I mock the interface of the <code>A</code> class (and set up an expectation for the callback) then I lose the implementation of <code>RegisterEventHandlers()</code>, which is the method I'm testing in the first place.</li>
  <li>Mocking the <code>B</code> class's event would be the best option, but I don't see what method I'd have to intercept to do this. Is there some way to set up a mock for an event, and intercept the <code>+=</code> method call?</li>
  </ul>
  
  <p>Is there a clean solution to this?</p>