public void PublishMessageTest()
        {
            int  numOfMessagesReceived = 0;
            bool finished = false;

            var serviceCollection = new ServiceCollection();
            var names             = new List <string>();

            serviceCollection.AddSingleton(names);
            var executionContext = new ServiceProviderMessageHandlerExecutionContext(serviceCollection);

            using (var bus = new RabbitMessageBus(connectionFactory,
                                                  serializer,
                                                  executionContext,
                                                  "RabbitMQMessageBusTests.PublishMessageTest", queueName: "RabbitMQMessageBusTests.PublishMessageTestQueue"))
            {
                // When any message received, increase the counter
                bus.MessageReceived += (x, y) => numOfMessagesReceived++;

                // When any message acknowledged, stop waiting the do the assertion.
                bus.MessageAcknowledged += (x, y) => finished = true;

                bus.Subscribe <NameChangedEvent, NameChangedEventHandler>();

                var event1 = new NameChangedEvent("daxnet");
                bus.Publish(event1);

                while (!finished)
                {
                    ;
                }
            }

            Assert.Equal(1, numOfMessagesReceived);
        }
        public static AmqpConfiguration GetDefault(string clientName, AmqpConnectionParameters connectionParameters)
        {
            // use the given connection parameters to create a rabbit connection
            RabbitConnection rabbitConnection = new RabbitConnection(connectionParameters);

            // use the connection to create a message bus
            IAmqpMessageBus amqpMessageBus = new RabbitMessageBus(rabbitConnection);

            // our default implementation of the topology manager is a composite of multiple
            // topology managers
            CompositeTopologyManager composite = new CompositeTopologyManager();
            composite.Append(new StaticTopologyManager());
            composite.Append(new GlobalTopologyManager(clientName, 300)); //TODO: Make the heartbeat interval configurable?
            composite.Append(new FallbackTopologyManager());

            IEventSerializer serializer = new GsonSerializer();

            AmqpConfiguration defaultConfiguration = new AmqpConfiguration();
            defaultConfiguration.ClientName = clientName;
            defaultConfiguration.ConnectionParameters = connectionParameters;
            defaultConfiguration.MessageBus = amqpMessageBus;
            defaultConfiguration.TopologyService = composite;
            defaultConfiguration.EventSerializer = serializer;

            return defaultConfiguration;
        }