Ejemplo n.º 1
0
 private void tryToMatch(PublishedMessage sender, Subscription receiver)
 {
     if (MessageRoute.TryToRoute(sender, receiver, out MessageRoute route,
                                 out PublisherSubscriberMismatch mismatch))
     {
         _routes.Add(route);
     }
Ejemplo n.º 2
0
        public void use_json_if_that_is_the_only_match()
        {
            var published = new PublishedMessage(typeof(Message1))
            {
                ContentTypes = new string[] { "application/json", "app/v2", "app/v3" },
                Transports   = new string[] { "loopback" }
            };

            var subscription = new Subscription(typeof(Message1), "loopback://one".ToUri());

            subscription.Accept = new string[] { "application/json", "app/v4", "app/v5" };

            MessageRoute.TryToRoute(published, subscription, out MessageRoute route, out PublisherSubscriberMismatch mismatch)
            .ShouldBeTrue();

            route.ContentType.ShouldBe("application/json");
        }
Ejemplo n.º 3
0
        public void mismatch_with_no_matching_content_types_and_transport()
        {
            var published = new PublishedMessage(typeof(Message1))
            {
                ContentTypes = new string[] { "one", "two" },
                Transports   = new string[] { "jasper" }
            };

            var subscription = new Subscription(typeof(Message1), "fake://one".ToUri());

            subscription.Accept = new string[] { "three" };

            MessageRoute.TryToRoute(published, subscription, out MessageRoute route, out PublisherSubscriberMismatch mismatch)
            .ShouldBeFalse();

            mismatch.IncompatibleContentTypes.ShouldBeTrue();
            mismatch.IncompatibleTransports.ShouldBeTrue();
        }
Ejemplo n.º 4
0
        public void mismatch_with_no_matching_content_types()
        {
            var published = new PublishedMessage(typeof(Message1))
            {
                ContentTypes = new string[] { "one", "two" }
            };

            var subscription = new Subscription(typeof(Message1), "loopback://one".ToUri());

            subscription.Accept = new string[] { "three" };

            MessageRoute.TryToRoute(published, subscription, out MessageRoute route, out PublisherSubscriberMismatch mismatch)
            .ShouldBeFalse();

            mismatch.IncompatibleContentTypes.ShouldBeTrue();
            mismatch.PublishedContentTypes.ShouldBe(published.ContentTypes);
            mismatch.SubscriberContentTypes.ShouldBe(subscription.Accept);
        }