public void RegisterAsyncHandler_NullLog_ThrowsArgumentNullException()
        {
            var manager = new OrionEventManager();

            Assert.Throws <ArgumentNullException>(
                () => manager.RegisterAsyncHandler <TestEvent>(async evt => await Task.Delay(100), null !));
        }
        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 RegisterAsyncHandler_Raise_ThrowsExceptionAsynchronously()
        {
            var manager = new OrionEventManager();
            var log     = Mock.Of <ILogger>();

            manager.RegisterAsyncHandler <TestEvent>(async evt =>
            {
                await Task.Delay(100);

                throw new InvalidOperationException();
            }, log);
            var evt = new TestEvent();

            manager.Raise(evt, log);

            // HACK: sleep here to ensure that the handler is finished.
            Thread.Sleep(1000);
        }
        public void RegisterAsyncHandler_Raise()
        {
            var manager = new OrionEventManager();
            var log     = Mock.Of <ILogger>();

            manager.RegisterAsyncHandler <TestEvent>(async evt =>
            {
                await Task.Delay(100);

                evt.Value = 100;
            }, log);
            var evt = new TestEvent();

            manager.Raise(evt, Logger.None);

            // HACK: sleep here to ensure that the handler is finished.
            Thread.Sleep(1000);

            Assert.Equal(100, evt.Value);
        }