public RequestChangeOfSupplierTests()
        {
            var services = new ServiceCollection();

            _connectionString =
                Environment.GetEnvironmentVariable("MarketData_IntegrationTests_ConnectionString");

            services.AddScoped <IDbConnectionFactory>(sp => new SqlDbConnectionFactory(_connectionString));
            services.AddScoped <IUnitOfWorkCallback, UnitOfWorkCallback>();
            services.AddScoped <ISystemDateTimeProvider, SystemDateTimeProviderStub>();
            services.AddScoped <IEventPublisher, EventPublisherStub>();
            services.AddScoped <IActorMessagePublisher, ActorMessagePublisher>();
            services.AddScoped <IMeteringPointRepository, MeteringPointRepository>();
            services.AddScoped <IEnergySupplierRepository, EnergySupplierRepository>();

            services.AddMediatR(new[]
            {
                typeof(RequestChangeSupplierCommandHandler).Assembly,
            });

            services.AddScoped(typeof(IPipelineBehavior <,>), typeof(UnitOfWorkHandlerBehavior <,>));
            services.AddScoped(typeof(IPipelineBehavior <,>), typeof(PublishIntegrationEventsHandlerBehavior <,>));
            services.AddScoped <IPipelineBehavior <RequestChangeOfSupplier, RequestChangeOfSupplierResult>, PublishActorMessageHandlerBehavior>();

            services.AddGreenEnergyHub(typeof(RequestChangeOfSupplier).Assembly);

            DapperNodaTimeSetup.Register();

            _serviceProvider          = services.BuildServiceProvider();
            _mediator                 = _serviceProvider.GetRequiredService <IMediator>();
            _meteringPointRepository  = _serviceProvider.GetRequiredService <IMeteringPointRepository>();
            _energySupplierRepository = _serviceProvider.GetRequiredService <IEnergySupplierRepository>();
            _unitOfWorkCallback       = _serviceProvider.GetRequiredService <IUnitOfWorkCallback>();
            _actorMessagePublisher    = _serviceProvider.GetRequiredService <IActorMessagePublisher>();
        }
 public PublishActorMessageHandlerBehavior(IActorMessagePublisher messagePublisher, IMediator mediator)
 {
     _messagePublisher = messagePublisher ?? throw new ArgumentNullException(nameof(messagePublisher));
     _mediator         = mediator ?? throw new ArgumentNullException(nameof(mediator));
 }