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));
 }
        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));
        }
 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)));
 }
 public void When_initialized_unknown_message_returns_empty()
 {
     var router = new StaticMessageRouter(new[]
     {
         typeof(Message1)
     });
     Assert.IsEmpty(router.GetDestinationFor(typeof(Message2)));
 }
        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)));
        }
        public void When_initialized_unknown_message_returns_empty()
        {
            var router = new StaticMessageRouter(new[]
            {
                typeof(Message1)
            });

            Assert.IsEmpty(router.GetDestinationFor(typeof(Message2)));
        }
        public void Test_that_expose_the_issue_with_the_current_codebase_assuming_that_routes_can_be_updated()
        {
            var router = new StaticMessageRouter(new Type[0]);

            var overrideAddress = Address.Parse("override");

            router.RegisterMessageRoute(typeof(Message1), Address.Parse("first"));
            router.RegisterMessageRoute(typeof(Message1), overrideAddress);

            Assert.AreEqual(overrideAddress, router.GetDestinationFor(typeof(Message1)).Single());
        }
        public void Test_that_expose_the_issue_with_the_current_codebase_assuming_that_routes_can_be_updated()
        {
            var router = new StaticMessageRouter(new Type[0]);

            var overrideAddress = Address.Parse("override");

            router.RegisterMessageRoute(typeof(Message1), Address.Parse("first"));
            router.RegisterMessageRoute(typeof(Message1), overrideAddress);

            Assert.AreEqual(overrideAddress, router.GetDestinationFor(typeof(Message1)).Single());
        }
        public void When_registered_registering_multiple_addresses_for_same_type_same_number_of_addresses_are_returned()
        {
            var baseType = typeof(BaseMessage);
            var router   = new StaticMessageRouter(Enumerable.Empty <Type>());
            var addressA = new Address("BaseMessage", "A");

            router.RegisterEventRoute(baseType, addressA);
            var addressB = new Address("BaseMessage", "b");

            router.RegisterEventRoute(baseType, addressB);

            Assert.AreEqual(2, router.GetDestinationFor(baseType).Count);
        }
예제 #10
0
        public void When_registered_registering_multiple_addresses_for_same_type_and_using_plainmessages_last_one_wins()
        {
            var baseType = typeof(BaseMessage);
            var router   = new StaticMessageRouter(Enumerable.Empty <Type>());
            var addressA = new Address("BaseMessage", "A");

            router.RegisterMessageRoute(baseType, addressA);
            var addressB = new Address("BaseMessage", "b");

            router.RegisterMessageRoute(baseType, addressB);

            Assert.AreEqual(1, router.GetDestinationFor(baseType).Count);
        }
        public void When_registered_registering_multiple_addresses_for_same_type_and_using_plainmessages_last_one_wins()
        {
            SettingsHolder.SetProperty <DefaultAutoSubscriptionStrategy>(s => s.SubscribePlainMessages, true);
            var baseType = typeof(BaseMessage);
            var router   = new StaticMessageRouter(Enumerable.Empty <Type>());
            var addressA = new Address("BaseMessage", "A");

            router.RegisterMessageRoute(baseType, addressA);
            var addressB = new Address("BaseMessage", "b");

            router.RegisterMessageRoute(baseType, addressB);

            Assert.AreEqual(1, router.GetDestinationFor(baseType).Count);
        }
예제 #12
0
        public void When_registered_registering_multiple_addresses_for_same_type_and_using_plainmessages_last_one_wins()
        {
            var baseType = typeof(BaseMessage);
            var router = new StaticMessageRouter(Enumerable.Empty<Type>());
            var addressA = new Address("BaseMessage", "A");
            router.RegisterMessageRoute(baseType, addressA);
            var addressB = new Address("BaseMessage", "b");
            router.RegisterMessageRoute(baseType, addressB);

            Assert.AreEqual(1, router.GetDestinationFor(baseType).Count);
        }
예제 #13
0
        public void When_registered_registering_multiple_addresses_for_same_type_same_number_of_addresses_are_returned()
        {
            var baseType = typeof(BaseMessage);
            var router = new StaticMessageRouter(Enumerable.Empty<Type>());
            var addressA = new Address("BaseMessage", "A");
            router.RegisterEventRoute(baseType, addressA);
            var addressB = new Address("BaseMessage", "b");
            router.RegisterEventRoute(baseType, addressB);

            Assert.AreEqual(2, router.GetDestinationFor(baseType).Count);
        }
 public void When_initialized_unknown_message_returns_undefined()
 {
     var router = new StaticMessageRouter(new[] { typeof(Message1) });
     Assert.AreEqual(Address.Undefined, router.GetDestinationFor(typeof(Message2)));
 }
        public void When_registered_registering_multiple_addresses_for_same_type_and_using_plainmessages_last_one_wins()
        {
            SettingsHolder.SetProperty<DefaultAutoSubscriptionStrategy>(s => s.SubscribePlainMessages, true);
            var baseType = typeof(BaseMessage);
            var router = new StaticMessageRouter(Enumerable.Empty<Type>());
            var addressA = new Address("BaseMessage", "A");
            router.RegisterMessageRoute(baseType, addressA);
            var addressB = new Address("BaseMessage", "b");
            router.RegisterMessageRoute(baseType, addressB);

            Assert.AreEqual(1, router.GetDestinationFor(baseType).Count);
        }
예제 #16
0
        public void When_initialized_known_message_returns_undefined()
        {
            var router = new StaticMessageRouter(new[] { typeof(Message1) });

            Assert.AreEqual(Address.Undefined, router.GetDestinationFor(typeof(Message1)));
        }