Пример #1
0
        internal Scenario(GrpcScenarioOptions options)
        {
            if (options.GrpcClients.Any() == false && options.Client == null)
            {
                throw new BardConfigurationException("Client not set");
            }

            _eventAggregator = new EventAggregator();

            _logWriter = new LogWriter(options.LogMessage, _eventAggregator);

            var originalClient = options.Client ?? throw new BardConfigurationException("client not set.");

            var bardClient = HttpClientBuilder
                             .CreateFullLoggingClient(originalClient, _logWriter, options.BadRequestProvider, _eventAggregator);

            _clientFactory = new GrpcClientFactory(options.GrpcClients, bardClient, _logWriter);

            _api = new Api(bardClient);

            var pipeline = new PipelineBuilder(_logWriter);

            Context = new GrpcScenarioContext(pipeline, _api, _logWriter,
                                              options.Services, _clientFactory);

            _when = new When(_api, _eventAggregator, _logWriter);

            _then = new Then(null, _logWriter);

            _eventAggregator.Subscribe(_then);
            _eventAggregator.Subscribe(pipeline);
        }
Пример #2
0
 internal GrpcScenarioContext(IPipelineBuilder pipelineBuilder,
                              IApi api, LogWriter logWriter, IServiceProvider?services,
                              GrpcClientFactory grpcClientFactory) : base(
         pipelineBuilder, api, logWriter, services, grpcClientFactory.Create)
 {
 }