RaiseEvent isn't attached
bool eventFired = false;
var tellDontAsk = new SimpleTellDontAsk();
tellDontAsk.RaiseEvent += (o, e) =>
{
if (e.IsDo)
eventFired = true;
};
tellDontAsk.doSomething("test message");
Assert.IsTrue(eventFired);
Also if you want to use your own EventArgs "EventHandlerArgs" you should go for the Generic EventHandler.
The eventargs shouldnt be provided in the parameters to the method, they should be created when we need to raise the event.
public class SimpleTellDontAsk : ISomeEvent
{
public void doSomething(string text)
{
Console.WriteLine("Email this message {0}", text);
//sending message with email
if (RaiseEvent != null) //Check if we have listeners
{
EventHandlerArgs args = new EventHandlerArgs();
args.IsDo = true;
RaiseEvent(this, args);
}
}
public event EventHandler<EventHandlerArgs> RaiseEvent;
}