public void IgnoresExceptions() { var target = new FilteringEventDispatcher(); target.Subscribe(evt => { throw new Exception(); }); target.Send(new Event()); }
public void CanFilterUsingTypeParameter() { var calls = 0; var target = new FilteringEventDispatcher(); target.On <Event>(e => calls++); target.Send(new Event()); Assert.AreEqual(1, calls); }
public void CanFilterUsingTypeExpression() { var target = new FilteringEventDispatcher(); int calls = 0; target.Subscribe(evt => calls++, evt => evt is Event); target.Send(new Event()); Assert.AreEqual(1, calls); }
public void CanRegisterGenericHandler() { var target = new FilteringEventDispatcher(); int calls = 0; target.Subscribe(evt => calls++); target.Send(new Event()); Assert.AreEqual(1, calls); }
public void CanFilter() { var target = new FilteringEventDispatcher(); int calls = 0; target.Subscribe(evt => calls++, evt => false); target.Send(new Event()); Assert.AreEqual(0, calls); }
public void CanUnregisterGenericHandler() { var target = new FilteringEventDispatcher(); int calls = 0; Action <IEvent> handler = evt => calls++; target.Subscribe(handler); target.Send(new Event()); Assert.AreEqual(1, calls); target.Unsubscribe(handler); calls = 0; target.Send(new Event()); Assert.AreEqual(0, calls); }