public void DirectBindingWithQueueName()
        {
            var directExchange = new DirectExchange("d");
            var binding        = BindingBuilder.Bind(queue).To(directExchange).WithQueueName();

            Assert.NotNull(binding);
            Assert.Equal(directExchange.ExchangeName, binding.Exchange);
            Assert.Equal(Binding.DestinationType.QUEUE, binding.Type);
            Assert.Equal(queue.QueueName, binding.Destination);
            Assert.Equal(queue.QueueName, binding.RoutingKey);
        }
        public void FanoutBinding()
        {
            var fanoutExchange = new FanoutExchange("f");
            var binding        = BindingBuilder.Bind(queue).To(fanoutExchange);

            Assert.NotNull(binding);
            Assert.Equal(fanoutExchange.ExchangeName, binding.Exchange);
            Assert.Equal(string.Empty, binding.RoutingKey);
            Assert.Equal(Binding.DestinationType.QUEUE, binding.Type);
            Assert.Equal(queue.QueueName, binding.Destination);
        }
        public void HeaderBinding()
        {
            var headersExchange = new HeadersExchange("h");
            var headerKey       = "headerKey";
            var binding         = BindingBuilder.Bind(queue).To(headersExchange).Where(headerKey).Exists();

            Assert.NotNull(binding);
            Assert.Equal(headersExchange.ExchangeName, binding.Exchange);
            Assert.Equal(Binding.DestinationType.QUEUE, binding.Type);
            Assert.Equal(queue.QueueName, binding.Destination);
            Assert.Equal(string.Empty, binding.RoutingKey);
        }
        public void TopicBinding()
        {
            var topicExchange = new TopicExchange("t");
            var routingKey    = "r";
            var binding       = BindingBuilder.Bind(queue).To(topicExchange).With(routingKey);

            Assert.NotNull(binding);
            Assert.Equal(topicExchange.ExchangeName, binding.Exchange);
            Assert.Equal(Binding.DestinationType.QUEUE, binding.Type);
            Assert.Equal(queue.QueueName, binding.Destination);
            Assert.Equal(routingKey, binding.RoutingKey);
        }
        public void ExchangeBinding()
        {
            var directExchange = new DirectExchange("d");
            var fanoutExchange = new FanoutExchange("f");
            var binding        = BindingBuilder.Bind(directExchange).To(fanoutExchange);

            Assert.NotNull(binding);
            Assert.Equal(fanoutExchange.ExchangeName, binding.Exchange);
            Assert.Equal(Binding.DestinationType.EXCHANGE, binding.Type);
            Assert.Equal(directExchange.ExchangeName, binding.Destination);
            Assert.Equal(string.Empty, binding.RoutingKey);
        }
        public void CustomBinding()
        {
            var argumentobject = new object();
            var customExchange = new CustomExchange("c");
            var routingKey     = "r";
            var binding        = BindingBuilder.
                                 Bind(queue).
                                 To(customExchange).
                                 With(routingKey).
                                 And(new Dictionary <string, object>()
            {
                { "k", argumentobject }
            });

            Assert.NotNull(binding);
            Assert.Equal(argumentobject, binding.Arguments["k"]);
            Assert.Equal(customExchange.ExchangeName, binding.Exchange);
            Assert.Equal(Binding.DestinationType.QUEUE, binding.Type);
            Assert.Equal(queue.QueueName, binding.Destination);
            Assert.Equal(routingKey, binding.RoutingKey);
        }