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>();
        }
Beispiel #2
0
 public RequestChangeSupplierCommandHandler(
     IRuleEngine <RequestChangeOfSupplier> ruleEngine,
     IMeteringPointRepository meteringPointRepository,
     ISystemDateTimeProvider systemTimeProvider,
     IEnergySupplierRepository energySupplierRepository)
 {
     _ruleEngine = ruleEngine ?? throw new ArgumentNullException(nameof(ruleEngine));
     _meteringPointRepository  = meteringPointRepository ?? throw new ArgumentNullException(nameof(meteringPointRepository));
     _systemTimeProvider       = systemTimeProvider ?? throw new ArgumentNullException(nameof(systemTimeProvider));
     _energySupplierRepository = energySupplierRepository ?? throw new ArgumentNullException(nameof(energySupplierRepository));
 }