public void Create_ThenValid()
        {
            var          services       = new ServiceCollection();
            const string connectionName = "connection-name-test";
            var          baseAddress    = new Uri("rabbitmq://localhost");

            var inMemoryHostBuilder = new InMemoryHostBuilder(services, connectionName, baseAddress);

            Assert.Same(services, inMemoryHostBuilder.Services);
            Assert.Equal(connectionName, inMemoryHostBuilder.ConnectionName);

            Assert.Contains(services, item =>
                            item.Lifetime == ServiceLifetime.Singleton &&
                            item.ServiceType == typeof(IBusHostFactory) &&
                            item.ImplementationInstance == inMemoryHostBuilder);

            inMemoryHostBuilder.UseHostAccessor();

            using (var serviceProvider = services.BuildServiceProvider())
            {
                var hostAccessor = serviceProvider.GetRequiredService <IHostAccessor>();

                var inMemoryHostBefore = hostAccessor.GetHost <IInMemoryHost>(connectionName);
                Assert.Null(inMemoryHostBefore);

                var busControl = inMemoryHostBuilder.Create(serviceProvider);
                Assert.NotNull(busControl);

                var inMemoryHostAfter = hostAccessor.GetHost <IInMemoryHost>(connectionName);
                Assert.NotNull(inMemoryHostAfter);
                Assert.Equal(baseAddress, inMemoryHostAfter.Address);
            }
        }
        public void AddReceiveEndpoint_GivenConfigurator_ThenValid()
        {
            var          services       = new ServiceCollection();
            const string connectionName = "connection-name-test";
            var          baseAddress    = new Uri("rabbitmq://localhost");

            var inMemoryHostBuilder = new InMemoryHostBuilder(services, connectionName, baseAddress);

            var endpointConfiguratorWasCalled = false;

            inMemoryHostBuilder.AddReceiveEndpoint("queue-name-test", (IInMemoryReceiveEndpointBuilder builder) =>
            {
                Assert.Same(services, builder.Services);

                builder.AddConfigurator((host, endpointConfigurator, serviceProvider) =>
                {
                    endpointConfiguratorWasCalled = true;
                    Assert.Equal(baseAddress, host.Address);
                });
            });

            using (var serviceProvider = services.BuildServiceProvider())
            {
                var busControl = inMemoryHostBuilder.Create(serviceProvider);
                Assert.NotNull(busControl);
                Assert.True(endpointConfiguratorWasCalled);
            }
        }