I think I get what you're saying. I think. Here's an example illustrating some of the event mocking stuff. If this isn't what you mean, it might help to post a snippet of code showing what you're trying to test. That is, if you're trying to test something that uses the "Somebody" class, show that; if you're just trying to test the "RaiseHello" method to see if it raises the event, show your test and point out what you think should be working.
Note that in the below version of your sample code I had to change a couple of things to actually get it to work. I made the Hello event on the Somebody class public and I changed RaiseHello to take an EventArgs parameter instead of just object so I could avoid the cast and simplify the code a bit.
public interface ISomeInterface
{
event EventHandler<EventArgs> Hello;
}
public class Somebody : ISomeInterface
{
public event EventHandler<EventArgs> Hello;
public void RaiseHello(EventArgs stateInfo)
{
if(null != Hello)
{
Hello(this, stateInfo);
}
}
}
[TestFixture]
[VerifyMocks]
public class MyTestFixture
{
[Test]
public void MyTest()
{
Somebody obj = new Somebody();
EventArgs expected = new EventArgs();
using(RecordExpectations recorder = RecorderManager.StartRecording())
{
// Mock the registration for the event.
((ISomeInterface)obj).Hello += null;
// Ensure we're raising the event with the expected arg.
obj.RaiseHello(expected);
recorder.CheckArguments();
}
// Attach a handler that throws an exception. If this handler
// gets called, the test will fail because of that exception.
// (If it's not called, it proves the mocking is running.)
((ISomeInterface)obj).Hello += (sender, e) => { throw new NotSupportedException(); };
// Raise the event.
obj.RaiseHello(expected);
// The [VerifyMocks] attribute will ensure the event was subscribed
// to and that we called RaiseHello with the correct args.
}
}