Beispiel #1
0
        public void AsyncEventHadlerTest()
        {
            var  dispatcher   = new EventDispatcher(_logFactory, "testBC");
            var  asyncHandler = new EventAsyncHandler(false);
            bool ack          = false;

            dispatcher.Wire("testBC", asyncHandler);
            dispatcher.Dispatch("testBC", "test", (delay, acknowledge) => { ack = acknowledge; });

            Assert.AreEqual(1, asyncHandler.HandledEvents.Count);
            Assert.True(ack, "Event handler was not processed properly");
        }
Beispiel #2
0
        public void ExceptionForAsyncEventHadlerTest()
        {
            var dispatcher  = new EventDispatcher(_logFactory, "testBC");
            var handler     = new EventAsyncHandler(true);
            int failedCount = 0;

            dispatcher.Wire("testBC", handler);
            dispatcher.Dispatch("testBC", "test", (delay, acknowledge) =>
            {
                if (!acknowledge)
                {
                    ++failedCount;
                }
            });

            Assert.AreEqual(0, handler.HandledEvents.Count);
            Assert.AreEqual(1, failedCount, "Event handler was not processed properly");
        }