Beispiel #1
0
        public void AddsMessageVersionPropertyIfNoCustomMessageProperties()
        {
            var sut = new SubscriptionFilter();

            sut.Build(new MessageBusOptions(), typeof(Models.Events.V2.AircraftLanded));

            Assert.Equal(2, int.Parse(sut.MessageProperties[_defaultMessageVersionPropertyName]));
        }
Beispiel #2
0
        private static List <MessageHandlerMapping> BuildMessageSubscriptions()
        {
            var subscriptionFilter = new SubscriptionFilter();

            subscriptionFilter.Build(new MessageBusOptions(), typeof(AircraftLandedHandler));

            return(new List <MessageHandlerMapping>
            {
                new MessageHandlerMapping(typeof(AircraftLandedHandler), typeof(AircraftTakenOffHandler), subscriptionFilter)
            });
        }
        protected static SubscriptionFilter BuildSubscriptionFilter <T>() where T : IMessage
        {
            var subscriptionFilter = new SubscriptionFilter
            {
                Label = typeof(T).Name
            };

            subscriptionFilter.Build(new MessageBusOptions(), typeof(T));

            return(subscriptionFilter);
        }
Beispiel #4
0
        public void LabelReturnsLabelIfSet(Type typeOfMessage, string label)
        {
            var sut = new SubscriptionFilter
            {
                Label = label
            };

            sut.Build(new MessageBusOptions(), typeOfMessage);

            Assert.Equal(label, sut.Label);
            Assert.Equal(label, sut.EffectiveMessageLabel);
        }
Beispiel #5
0
        public void ThrowsIfNoMessageTypeInCustomSubscriptionFilterProperties()
        {
            var sut = new SubscriptionFilter
            {
                MessageProperties = new Dictionary <string, string>
                {
                    { "SomethingElse", "AL" }
                }
            };

            sut.Build(new MessageBusOptions(), typeof(AircraftLanded));

            Assert.Throws <ArgumentNullException>(() => sut.EffectiveMessageLabel);
        }
Beispiel #6
0
        public void SubscribesToMessagesWithoutCustomSubscriptionFilter()
        {
            SubscriptionFilter actualSubscriptionFilter = null;

            _mockMessageHandlerResolver.Setup(m => m.SubcribeToMessage <AircraftLanded, AircraftLandedHandler>(
                                                  It.IsAny <SubscriptionFilter>())).Callback <SubscriptionFilter>(s => actualSubscriptionFilter = s);

            _sut.SubscribeToMessage <AircraftLanded, AircraftLandedHandler>();

            var subscriptionFilter = new SubscriptionFilter();

            subscriptionFilter.Build(new MessageBusOptions(), typeof(AircraftLanded));
            Assert.Equal(nameof(AircraftLanded), actualSubscriptionFilter.Label);
            Assert.Equal(new Dictionary <string, string>(), actualSubscriptionFilter.MessageProperties);
        }
Beispiel #7
0
        public void EffectiveMessageLabelReturnsMessageTypePropertyIfMessageTypePropertyIsSetAndLabelIsNotSet(Type typeOfMessage)
        {
            var sut = new SubscriptionFilter
            {
                MessageProperties = new Dictionary <string, string>
                {
                    { _defaultMessageTypePropertyName, typeOfMessage.Name }
                }
            };

            sut.Build(new MessageBusOptions(), typeOfMessage);

            Assert.Equal(typeOfMessage.Name, sut.MessageProperties[_defaultMessageTypePropertyName]);
            Assert.Null(sut.Label);
            Assert.False(sut.MessageProperties.ContainsKey(_defaultMessageVersionPropertyName));
            Assert.Equal(typeOfMessage.Name, sut.EffectiveMessageLabel);
        }