public async Task Should_preserve_headers_generated_by_custom_routing_strategy()
        {
            var behavior = new RoutingToDispatchConnector();
            Dictionary<string, string> headers = null;
            await behavior.Invoke(new TestableRoutingContext { RoutingStrategies = new List<RoutingStrategy> { new CustomRoutingStrategy() } }, context =>
                {
                    headers = context.Operations.First().Message.Headers;
                    return TaskEx.CompletedTask;
                });

            Assert.IsTrue(headers.ContainsKey("CustomHeader"));
        }
示例#2
0
        public async Task Should_preserve_headers_generated_by_custom_routing_strategy()
        {
            var behavior = new RoutingToDispatchConnector();
            Dictionary <string, string> headers = null;
            await behavior.Invoke(new TestableRoutingContext { RoutingStrategies = new List <RoutingStrategy> {
                                                                   new CustomRoutingStrategy()
                                                               } }, context =>
            {
                headers = context.Operations.First().Message.Headers;
                return(TaskEx.CompletedTask);
            });

            Assert.IsTrue(headers.ContainsKey("CustomHeader"));
        }
示例#3
0
        public async Task Should_not_dispatch_by_default()
        {
            var dispatched = false;
            var behavior   = new RoutingToDispatchConnector();
            var message    = new OutgoingMessage("ID", new Dictionary <string, string>(), new byte[0]);

            await behavior.Invoke(new RoutingContext(message,
                                                     new UnicastRoutingStrategy("Destination"), CreateContext(new SendOptions(), true)), c =>
            {
                dispatched = true;
                return(TaskEx.CompletedTask);
            });

            Assert.IsFalse(dispatched);
        }
        public async Task Should_dispatch_immediately_if_not_sending_from_a_handler()
        {
            var dispatched = false;
            var behavior   = new RoutingToDispatchConnector();
            var message    = new OutgoingMessage("ID", new Dictionary <string, string>(), new byte[0]);

            await behavior.Invoke(new RoutingContext(message,
                                                     new UnicastRoutingStrategy("Destination"), CreateContext(new SendOptions(), false)), c =>
            {
                dispatched = true;
                return(Task.CompletedTask);
            });

            Assert.IsTrue(dispatched);
        }
        public async Task Should_not_dispatch_by_default()
        {
            var dispatched = false;
            var behavior = new RoutingToDispatchConnector();
            var message = new OutgoingMessage("ID", new Dictionary<string, string>(), new byte[0]);

            await behavior.Invoke(new RoutingContext(message,
                new UnicastRoutingStrategy("Destination"), CreateContext(new SendOptions(), true)), c =>
                {
                    dispatched = true;
                    return TaskEx.CompletedTask;
                });

            Assert.IsFalse(dispatched);
        }
        public async Task Should_dispatch_immediately_if_user_requested()
        {
            var options = new SendOptions();
            options.RequireImmediateDispatch();

            var dispatched = false;
            var behavior = new RoutingToDispatchConnector();
            var message = new OutgoingMessage("ID", new Dictionary<string, string>(), new byte[0]);

            await behavior.Invoke(new RoutingContext(message,
                new UnicastRoutingStrategy("Destination"), CreateContext(options, true)), c =>
                {
                    dispatched = true;
                    return TaskEx.CompletedTask;
                });

            Assert.IsTrue(dispatched);
        }
示例#7
0
        public async Task Should_dispatch_immediately_if_user_requested()
        {
            var options = new SendOptions();

            options.RequireImmediateDispatch();

            var dispatched = false;
            var behavior   = new RoutingToDispatchConnector();
            var message    = new OutgoingMessage("ID", new Dictionary <string, string>(), new byte[0]);

            await behavior.Invoke(new RoutingContext(message,
                                                     new UnicastRoutingStrategy("Destination"), CreateContext(options, true)), c =>
            {
                dispatched = true;
                return(TaskEx.CompletedTask);
            });

            Assert.IsTrue(dispatched);
        }