public static async Task ScrapeAuditLog(IBusContext <IConnection> mainContext, ServiceCollection collection,
                                                DateTime startTime)
        {
            var exchangeName      = "Audit_Bestelling " + Guid.NewGuid();
            var connectionBuilder = new RabbitMQContextBuilder()
                                    .ReadFromEnvironmentVariables().WithExchange(exchangeName);

            var builder = new MicroserviceHostBuilder();

            builder
            .RegisterDependencies(collection)
            .WithContext(connectionBuilder.CreateContext())
            .ExitAfterIdleTime(new TimeSpan(0, 0, 2, 0))
            .UseConventions();

            builder.CreateHost().StartListeningInOtherThread();

            var publisher = new CommandPublisher(mainContext);

            var replayEventsCommand = new ReplayEventsCommand
            {
                ToTimestamp  = startTime.Ticks,
                ExchangeName = exchangeName
            };

            var result = await publisher.Publish <bool>(replayEventsCommand, "AuditlogReplayService",
                                                        "Minor.WSA.AuditLog.Commands.ReplayEventsCommand");
        }
        public void RegisterDependenciesAddsToExistingServiceCollection()
        {
            // Arrange
            var builder = new MicroserviceHostBuilder();

            ServiceCollection serviceCollection = new ServiceCollection();

            serviceCollection.AddTransient <TestType1>();

            // Act
            builder.RegisterDependencies(services => { services.AddTransient <TestType2>(); });
            builder.RegisterDependencies(serviceCollection);

            // Assert
            IServiceProvider serviceProvider = builder.ServiceCollection.BuildServiceProvider();

            Assert.IsNotNull(serviceProvider.GetService <TestType1>());
            Assert.IsNotNull(serviceProvider.GetService <TestType2>());
        }
        public void RegisterDependenciesInvokesConfigMethod()
        {
            // Arrange
            var  host          = new MicroserviceHostBuilder();
            bool hasBeenCalled = false;

            // Act
            host.RegisterDependencies(e => hasBeenCalled = true);

            // Assert
            Assert.IsTrue(hasBeenCalled);
        }
        public void RegisterDependenciesRegistersOneExtraDependency()
        {
            // Arrange
            var builder = new MicroserviceHostBuilder();

            // Act
            builder.RegisterDependencies(e =>
            {
                e.AddTransient <TestType1>();
            });

            // Assert
            Assert.AreEqual(2, builder.ServiceCollection.Count);

            IServiceProvider serviceProvider = builder.ServiceCollection.BuildServiceProvider();

            Assert.IsNotNull(serviceProvider.GetService <TestType1>());
        }