コード例 #1
0
        public void WhenResolvingUnknownMessageTypes_ShouldReturnDefaultHandler()
        {
            var dependencies = MockDependencyResolver
                               .Create()
                               .Register <IPoisonMessageHandler>(null);

            var resolver = new MessageHandlerResolver(new[] { typeof(TestMessageHandler) }, dependencies);
            var headers  = new Dictionary <string, string> {
                { EventDataPropertyKeys.MessageType, UnknownMessageType }
            };
            var handler = resolver.GetHandler(headers, "test-message-0");

            Assert.IsType <UnknownTypeMessageHandler>(handler);
        }
コード例 #2
0
        public void WhenResolving_ShouldUseTypeFromMessageHeaders()
        {
            var dependencies = MockDependencyResolver
                               .Create()
                               .Register <IPoisonMessageHandler>(null);

            var resolver = new MessageHandlerResolver(new[] { typeof(TestMessageHandler) }, dependencies);
            var headers  = new Dictionary <string, string>
            {
                { EventDataPropertyKeys.MessageType, RegisteredMessageType },
                { EventDataPropertyKeys.MessageTypeVersion, "1" }
            };
            var handler = resolver.GetHandler(headers, "test-message-0");

            Assert.NotNull(handler);
            Assert.IsType <TestMessageHandler>(handler);
            Assert.Equal("TestMessageHandler", handler.Name);
        }