public void RegisterHandler_Raise_EventCanceled() { var manager = new OrionEventManager(); var log = Mock.Of <ILogger>(); manager.RegisterHandler <TestEvent2>(TestEvent2Handler, log); manager.RegisterHandler <TestEvent2>(TestEvent2Handler2, log); var evt = new TestEvent2(); manager.Raise(evt, Logger.None); Assert.Equal(0, evt.Value); }
public void RegisterHandler_Raise() { var manager = new OrionEventManager(); var log = Mock.Of <ILogger>(); manager.RegisterHandler <TestEvent>(evt => evt.Value = 100, log); var evt = new TestEvent(); manager.Raise(evt, Logger.None); Assert.Equal(100, evt.Value); }
public void RegisterAsyncHandler_Raise_EventCanceled() { var manager = new OrionEventManager(); var log = Mock.Of <ILogger>(); manager.RegisterHandler <TestEvent2>(TestEvent2Handler, log); manager.RegisterAsyncHandler <TestEvent2>(TestEvent2Handler2Async, log); var evt = new TestEvent2(); manager.Raise(evt, Logger.None); // HACK: sleep here to ensure that the handler is finished. Thread.Sleep(1000); Assert.Equal(0, evt.Value); }
public void RegisterHandler_NullLog_ThrowsArgumentNullException() { var manager = new OrionEventManager(); Assert.Throws <ArgumentNullException>(() => manager.RegisterHandler <TestEvent>(evt => { }, null !)); }