コード例 #1
0
 public void When_inherited_registered_after_base_correct_address_is_returned_for_both()
 {
     var baseType = typeof(BaseMessage);
     var inheritedType = typeof(InheritedMessage);
     var router = new StaticMessageRouter(new[] { baseType, inheritedType });
     var baseAddress = new Address("baseAddress", "b");
     router.RegisterRoute(baseType, baseAddress);
     var inheritedAddress = new Address("inheritedAddress", "b");
     router.RegisterRoute(inheritedType, inheritedAddress);
     Assert.AreSame(baseAddress, router.GetDestinationFor(baseType));
     Assert.AreSame(inheritedAddress, router.GetDestinationFor(inheritedType));
 }
コード例 #2
0
        public void When_inherited_base_after_registered_correct_address_is_returned_for_both()
        {
            var baseType         = typeof(BaseMessage);
            var inheritedType    = typeof(InheritedMessage);
            var router           = new StaticMessageRouter(new[] { baseType, inheritedType });
            var inheritedAddress = new Address("inheritedAddress", "b");

            router.RegisterRoute(inheritedType, inheritedAddress);
            var baseAddress = new Address("baseAddress", "b");

            router.RegisterRoute(baseType, baseAddress);
            Assert.AreSame(baseAddress, router.GetDestinationFor(baseType));
            Assert.AreSame(inheritedAddress, router.GetDestinationFor(inheritedType));
        }
コード例 #3
0
 public void When_getting_route_correct_address_is_returned()
 {
     var router = new StaticMessageRouter(new[] { typeof(Message1) });
     var address = new Address("a","b");
     router.RegisterRoute(typeof(Message1), address);
     Assert.AreSame(address, router.GetDestinationFor(typeof(Message1)));
 }
コード例 #4
0
        void RegisterMessageOwnersAndBusAddress(IEnumerable <Type> knownMessages)
        {
            var unicastConfig = GetConfigSection <UnicastBusConfig>();
            var router        = new StaticMessageRouter(knownMessages);

            Configurer.RegisterSingleton <IRouteMessages>(router);

            if (unicastConfig == null)
            {
                return;
            }
            if (!string.IsNullOrWhiteSpace(unicastConfig.ForwardReceivedMessagesTo))
            {
                var forwardAddress = Address.Parse(unicastConfig.ForwardReceivedMessagesTo);
                busConfig.ConfigureProperty(b => b.ForwardReceivedMessagesTo, forwardAddress);
            }
            busConfig.ConfigureProperty(b => b.TimeToBeReceivedOnForwardedMessages, unicastConfig.TimeToBeReceivedOnForwardedMessages);

            var messageEndpointMappings = unicastConfig.MessageEndpointMappings.Cast <MessageEndpointMapping>()
                                          .OrderByDescending(m => m)
                                          .ToList();

            foreach (var mapping in messageEndpointMappings)
            {
                mapping.Configure((messageType, address) =>
                {
                    if (!MessageConventionExtensions.IsMessageType(messageType))
                    {
                        return;
                    }

                    router.RegisterRoute(messageType, address);
                });
            }
        }
コード例 #5
0
        public void When_getting_route_correct_address_is_returned()
        {
            var router  = new StaticMessageRouter(new[] { typeof(Message1) });
            var address = new Address("a", "b");

            router.RegisterRoute(typeof(Message1), address);
            Assert.AreSame(address, router.GetDestinationFor(typeof(Message1)));
        }
コード例 #6
0
 protected void RegisterOwnedMessageType <T>()
 {
     router.RegisterRoute(typeof(T), Address.Local);
 }