Example #1
0
        public void Scan_Any_DoesNotReturnNull()
        {
            // when
            var retVal = _sut.ScanForMessageHandlers();

            // then
            Assert.That(retVal, Is.Not.Null);
        }
Example #2
0
        /// <summary>
        /// Searches for all handlers and creates a handler chain called if a specific message is
        /// to be handled.
        /// </summary>
        private void GroupHandlersByHandledTypes()
        {
            IEnumerable <Type> messageHandlerTypes = _scanner.ScanForMessageHandlers();

            if (messageHandlerTypes != null)
            {
                foreach (Type msgHandler in messageHandlerTypes)
                {
                    var handlerInterfaceTypes = msgHandler.GetInterfaces().Where(IsMessageHandlerInterface);
                    foreach (Type handlerInterface in handlerInterfaceTypes)
                    {
                        Type handledMsgType = handlerInterface.GetGenericArguments().First();

                        AddToScannedHandlers(handledMsgType, msgHandler);
                    }
                }
            }
        }