A "normal" event on an instance ignores null subscriptions. If I do so on a substituted interface, a null subscription leads to an exception. I have a not so nice legacy code with different listeners to an event an one class that does null-attach internally under some conditions, would be nice if this behaviour would be able to be tested as well. Example code for the problem:
public interface IEventSource
{
event EventHandler<EventArgs> MyEvent;
}
[TestMethod]
public void TestEvent()
{
var raised = false;
var source = Substitute.For<IEventSource>();
source.MyEvent += null; //<- this leads to fail on Raise
source.MyEvent += (s, e) => raised = true;
source.MyEvent += Raise.EventWith(new EventArgs());
Assert.IsTrue(raised);
}´´´
A "normal" event on an instance ignores null subscriptions. If I do so on a substituted interface, a null subscription leads to an exception. I have a not so nice legacy code with different listeners to an event an one class that does null-attach internally under some conditions, would be nice if this behaviour would be able to be tested as well. Example code for the problem: